axvdo

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package axvdo provides a Go wrapper around the libvdo C library. This package abstracts the complexities of direct C interaction, offering Go developers a more accessible and idiomatic way to work with Video capture API.

This wrapper aims to simplify the development of applications interacting with the Axis vdo system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VdoErrorIsExpected

func VdoErrorIsExpected(gerr **C.GError) bool

Check if error is expected. Expected errors typically occur as a result of force stopping 'com.axis.Vdo1.System'. This class of errors should not be logged as failures, when they occur the recipient is expected to either silently recover or exit informing the user that vdo is currently unavailable. https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-error_8h.html#ac748fae792da6c96a4cba4619a3a3d90

func VdoFormatIsEncoded

func VdoFormatIsEncoded(format VdoFormat) bool

VdoFormatIsEncoded checks if the given format is one of the encoded formats (H264, H265, or JPEG).

func VdoFormatIsMotionEncoded

func VdoFormatIsMotionEncoded(format VdoFormat) bool

VdoFormatIsMotionEncoded checks if the given format is one of the motion encoded formats. It is considered motion encoded if it is encoded but not JPEG.

func VdoFrameIsEncoded

func VdoFrameIsEncoded(frameType VdoFrameType) bool

VdoFrameIsEncoded checks if the given frame type is one of the encoded types.

Types

type CropArea

type CropArea struct {
	Width  int
	Height int
	X      int
	Y      int
}

CropArea defines the dimensions and position of the crop area.

func CalculateCropDimensions

func CalculateCropDimensions(inputWidth, inputHeight, streamWidth, streamHeight int) CropArea

calculateCropDimensions calculates the cropping dimensions and position based on input and stream sizes.

type StreamRotation

type StreamRotation int
const (
	StreamRotationNone StreamRotation = 0
	StreamRotation90   StreamRotation = 90
	StreamRotation180  StreamRotation = 180
	StreamRotation270  StreamRotation = 270
)

type StreamStats

type StreamStats struct {
	// Bitrate of the video stream in bits per second.
	Bitrate uint32
	// BufferType describes the type of buffering strategy used for the stream.
	BufferType string
	// Channel represents the specific channel or stream identifier.
	Channel uint32
	// Format specifies the video format used in the stream.
	Format int16
	// Framerate is the number of frames per second in the video stream.
	Framerate uint32
	// GOPLength represents the length of a Group of Pictures in frames.
	GOPLength uint32
	// H26xIntraRefresh indicates the intra refresh rate for H.264/H.265 video streams.
	H26xIntraRefresh uint32
	// Height of the video stream in pixels.
	Height uint32
	// HorizontalFlip indicates whether the video stream is flipped horizontally.
	HorizontalFlip bool
	// ID is a unique identifier for the stream.
	ID uint32
	// InitialBitrate is the initial bitrate of the video stream in bits per second.
	InitialBitrate uint32
	// InitialQPb is the initial quantization parameter for B-frames.
	InitialQPb uint32
	// InitialQPi is the initial quantization parameter for I-frames.
	InitialQPi uint32
	// InitialQPp is the initial quantization parameter for P-frames.
	InitialQPp uint32
	// Overlays describes any overlays applied to the video stream.
	Overlays string
	// Peers represents the number of peers connected to the video stream.
	Peers uint32
	// QPb is the current quantization parameter for B-frames.
	QPb uint32
	// QPi is the current quantization parameter for I-frames.
	QPi uint32
	// QPp is the current quantization parameter for P-frames.
	QPp uint32
	// Rotation indicates the rotation applied to the video stream, in degrees.
	Rotation uint32
	// Running indicates whether the video stream is currently active.
	Running bool
	// SquarePixel indicates whether square pixels are used in the video stream.
	SquarePixel uint32
	// StatisticsAccumulatedBytes is the total number of bytes processed by the stream.
	StatisticsAccumulatedBytes uint64
	// StatisticsAccumulatedIDRBytes is the total number of IDR frame bytes processed by the stream.
	StatisticsAccumulatedIDRBytes uint64
	// StatisticsBitCount is the total number of bits processed by the stream.
	StatisticsBitCount uint32
	// StatisticsBitrate is the current bitrate of the video stream in bits per second.
	StatisticsBitrate uint32
	// StatisticsDuration is the total duration of video processed by the stream, in milliseconds.
	StatisticsDuration int64
	// StatisticsDynamicFramerate is the current dynamic frame rate of the video stream.
	StatisticsDynamicFramerate uint32
	// StatisticsFailedFrames is the total number of frames that failed to process.
	StatisticsFailedFrames uint32
	// StatisticsFrameCount is the total number of frames processed by the stream.
	StatisticsFrameCount uint32
	// StatisticsFramerate is the current frame rate of the video stream.
	StatisticsFramerate uint32
	// StatisticsIDRFrameCount is the total number of IDR frames processed by the stream.
	StatisticsIDRFrameCount uint32
	// StatisticsLastFrameTS is the timestamp of the last frame processed.
	StatisticsLastFrameTS uint64
	// StatisticsReclaimCount is the number of times stream resources have been reclaimed.
	StatisticsReclaimCount uint32
	// Width of the video stream in pixels.
	Width uint32
	// ZipProfile indicates the compression profile used for the video stream.
	ZipProfile int16
}

StreamStats holds statistical information about a video stream, including metrics such as bitrate, frame rate, resolution, and more. It provides a detailed view of the stream's current configuration and performance.

func (*StreamStats) PrintStreamStats

func (s *StreamStats) PrintStreamStats()

PrintStreamStats prints the fields of the StreamStats.

type VdoBuffer

type VdoBuffer struct {
	Ptr *C.VdoBuffer
}

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-buffer_8h.html

func NewVdoBufferFull

func NewVdoBufferFull(fd int, capacity uint, offset uint64, settings *VdoMap) *VdoBuffer

NewVdoBufferFull creates a buffer with custom properties. Default: VDO_BUFFER_ACCESS_ANY_RW (suitable for producers) The fd will not be closed by unref. TODO: opaque https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-buffer_8h.html#a097843481f6052a45fa46a6ca359750a

func Snapshot

func Snapshot(settings *VdoMap) (*VdoBuffer, error)

Fetches a single VdoBuffer containing a frame. Convenience function for fetching a single frame. Free the buffer with unref.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a4b4c0f2124280bde265491c08bd2f47c

func (*VdoBuffer) GetBytes

func (b *VdoBuffer) GetBytes() ([]byte, error)

GetBytes returns the data of the VdoBuffer as a Go byte slice. Note: This operation copies the data from C memory to Go memory.

func (*VdoBuffer) GetBytesUnsafe

func (b *VdoBuffer) GetBytesUnsafe() ([]byte, error)

GetBytes returns the data of the VdoBuffer as a directly mapped byte slice. Note: This operation should be use carefully regarding the lifetime of the memory and avoiding memory corruption or access violations It's critical to ensure that returned bytes slice is not used after buffer unref

func (*VdoBuffer) GetData

func (b *VdoBuffer) GetData() (unsafe.Pointer, error)

GetData returns a pointer to the underlying buffer data. Note: Beware this pointer is only valid for as long as the VdoBuffer itself is valid.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-buffer_8h.html#a3d39e2466d23b62e52a0fbfd10a968a3

func (*VdoBuffer) GetFrame

func (b *VdoBuffer) GetFrame() (*VdoFrame, error)

GetFrame returns a pointer to the underlying frame. Note: The returned frame type and handling would depend on further definitions and usage.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-buffer_8h.html#a5367ff8edb99976f0b22a2809d44c097

func (*VdoBuffer) GetOpaque

func (b *VdoBuffer) GetOpaque() unsafe.Pointer

GetOpaque returns user-provided custom information. The opaque pointer has no predefined meaning inside the vdo framework itself, it is meant to facilitate interoperability with other existing frameworks as well as caching the buffer data pointer(see vdo_buffer_get_data).

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-buffer_8h.html#a231bbe5da68795986d481253c879bc11

func (*VdoBuffer) Unref

func (b *VdoBuffer) Unref()

Unref/Free the VdoStream

type VdoBufferAccess

type VdoBufferAccess uint
const (
	VdoBufferAccessNone  VdoBufferAccess = 0
	VdoBufferAccessCPURd VdoBufferAccess = 1 << 0
	VdoBufferAccessDEVRd VdoBufferAccess = 1 << 1
	VdoBufferAccessAnyRd VdoBufferAccess = VdoBufferAccessCPURd | VdoBufferAccessDEVRd
	VdoBufferAccessCPUWr VdoBufferAccess = 1 << 8
	VdoBufferAccessDEVWr VdoBufferAccess = 1 << 9
	VdoBufferAccessAnyWr VdoBufferAccess = VdoBufferAccessCPUWr | VdoBufferAccessDEVWr
	VdoBufferAccessCPURW VdoBufferAccess = VdoBufferAccessCPURd | VdoBufferAccessCPUWr
	VdoBufferAccessDEVRW VdoBufferAccess = VdoBufferAccessDEVRd | VdoBufferAccessDEVWr
	VdoBufferAccessAnyRW VdoBufferAccess = VdoBufferAccessCPURW | VdoBufferAccessDEVRW
)

type VdoBufferStrategy

type VdoBufferStrategy int
const (
	VdoBufferStrategyNone     VdoBufferStrategy = 0
	VdoBufferStrategyInput    VdoBufferStrategy = 1
	VdoBufferStrategyExternal VdoBufferStrategy = 2
	VdoBufferStrategyExplicit VdoBufferStrategy = 3
	VdoBufferStrategyInfinite VdoBufferStrategy = 4
)

type VdoChannel

type VdoChannel struct {
	Ptr *C.VdoChannel
}

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html

func VdoChannelGet

func VdoChannelGet(channel_nbr uint) (*VdoChannel, error)

Get an existing channel. Create a new VdoChannel object representing an existing channel session with the specified channel number.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#ae5223c6a11ae8f3583457c4917a0b820

func (*VdoChannel) ChooseStreamResolution

func (c *VdoChannel) ChooseStreamResolution(reqWidth, reqHeight int) (*VdoResolution, error)

ChooseStreamResolution finds the smallest resolution that meets or exceeds the requested dimensions

func (*VdoChannel) GetInfo

func (c *VdoChannel) GetInfo() (*VdoMap, error)

Get the info for this channel. This function is called in order to get a pointer to the info map for this channel. The returned pointer is a pointer to a newly allocated VdoMap owned by the caller of this function

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#a19ca10165dba07f8295cd0933bfcaa49

func (*VdoChannel) GetResolutions

func (c *VdoChannel) GetResolutions(filter *VdoMap) ([]VdoResolution, error)

Fetch all valid resolutions for a channel with specified stream format. Get a VdoResolutionSet of valid resolutions. Specifying filter or NULL for default.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#ab95177576e046dd6a42c9f87013089ec

func (*VdoChannel) GetSettings

func (c *VdoChannel) GetSettings() (*VdoMap, error)

Get the settings for this channel. This function is called in order to get a pointer to the settings map for this channel. The returned pointer is a pointer to a newly allocated VdoMap owned by the caller of this function. For example:

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#a13a6f7939f63317f8b8798e9f3a75ea0

func (*VdoChannel) SetFramerate

func (c *VdoChannel) SetFramerate(framerate float32) error

Update the framerate for the specified channel. This function is invoked in order to update the framerate of a channel. All streams that are connected to this channel may be changed. Only streams with a higher fps set than the channel framerate will be affected.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#a44e1103d8690783c53103d326e9da5e0

type VdoChunk

type VdoChunk struct {
	Data unsafe.Pointer // Pointer to data
	Size uintptr        // Size of the data in bytes
	Type VdoChunkType   // Type of the chunk, based on the VdoChunkType enum
}

VdoChunk represents a chunk of data with a specified type.

type VdoChunkType

type VdoChunkType uint
const (
	VdoChunkNone  VdoChunkType = 0
	VdoChunkError VdoChunkType = 1 << 31
)

type VdoError

type VdoError struct {
	Code     VdoErrorCode
	Message  string
	Expected bool
}

VdoStream Error, a glib error but with vdo error codes

func (*VdoError) Error

func (e *VdoError) Error() string

func (*VdoError) ErrorCodeString

func (e *VdoError) ErrorCodeString() string

type VdoErrorCode

type VdoErrorCode int

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-types_8h_source.html VdoError represents the error codes for VDO operations. Used internaly

const (
	VdoErrorCodeNotFound VdoErrorCode = iota + 1
	VdoErrorCodeExists
	VdoErrorCodeInvalidArgument
	VdoErrorCodePermissionDenied
	VdoErrorCodeNotSupported
	VdoErrorCodeClosed
	VdoErrorCodeBusy
	VdoErrorCodeIO
	VdoErrorCodeHAL
	VdoErrorCodeDBus
	VdoErrorCodeOOM
	VdoErrorCodeIdle
	VdoErrorCodeNoData
	VdoErrorCodeNoBufferSpace
	VdoErrorCodeBufferFailure
	VdoErrorCodeInterfaceDown
	VdoErrorCodeFailed
	VdoErrorCodeFatal
	VdoErrorCodeNotControlled
	VdoErrorCodeNoEvent
)

type VdoFormat

type VdoFormat int

VdoFormat corresponds to the C enum VdoFormat.

const (
	VdoFormatNone      VdoFormat = C.VDO_FORMAT_NONE
	VdoFormatH264      VdoFormat = C.VDO_FORMAT_H264
	VdoFormatH265      VdoFormat = C.VDO_FORMAT_H265
	VdoFormatJPEG      VdoFormat = C.VDO_FORMAT_JPEG
	VdoFormatYUV       VdoFormat = C.VDO_FORMAT_YUV
	VdoFormatBayer     VdoFormat = C.VDO_FORMAT_BAYER
	VdoFormatIVS       VdoFormat = C.VDO_FORMAT_IVS
	VdoFormatRAW       VdoFormat = C.VDO_FORMAT_RAW
	VdoFormatRGBA      VdoFormat = C.VDO_FORMAT_RGBA
	VdoFormatRGB       VdoFormat = C.VDO_FORMAT_RGB
	VdoFormatPlanarRGB VdoFormat = C.VDO_FORMAT_PLANAR_RGB
)

func VdoFrameIsOfFormat

func VdoFrameIsOfFormat(frameType VdoFrameType) VdoFormat

VdoFrameIsOfFormat returns the VdoFormat corresponding to the given VdoFrameType.

type VdoFrame

type VdoFrame struct {
	Ptr *C.VdoFrame
}

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-frame_8h.html

func (*VdoFrame) GetCustomTimestamp

func (f *VdoFrame) GetCustomTimestamp() int64

GetCustomTimestamp returns a custom timestamp for this frame.

func (*VdoFrame) GetExtraInfo

func (f *VdoFrame) GetExtraInfo() *VdoMap

GetExtraInfo returns the extra info of this frame.

func (*VdoFrame) GetFd

func (f *VdoFrame) GetFd() int

GetFd returns a file descriptor for this frame.

func (*VdoFrame) GetFrameType

func (f *VdoFrame) GetFrameType() VdoFrameType

GetFrameType returns the type of this frame.

func (*VdoFrame) GetHeaderSize

func (f *VdoFrame) GetHeaderSize() int

GetHeaderSize returns the size of any H264/H265 headers contained in this frame.

func (*VdoFrame) GetIsLastBuffer

func (f *VdoFrame) GetIsLastBuffer() bool

GetIsLastBuffer tests whether this frame is the last buffer.

func (*VdoFrame) GetOpaque

func (f *VdoFrame) GetOpaque() unsafe.Pointer

GetOpaque returns a pointer to the opaque data of this frame.

func (*VdoFrame) GetSequenceNbr

func (f *VdoFrame) GetSequenceNbr() uint

GetSequenceNbr returns the sequence number of this frame.

func (*VdoFrame) GetSize

func (f *VdoFrame) GetSize() uint

GetSize returns the size of this frame.

func (*VdoFrame) GetTimestamp

func (f *VdoFrame) GetTimestamp() uint64

GetTimestamp returns the timestamp of this frame.

func (*VdoFrame) Memmap

func (f *VdoFrame) Memmap() unsafe.Pointer

Memmap maps the frame into current process memory. Returns a pointer to the data.

func (*VdoFrame) SetCustomTimestamp

func (f *VdoFrame) SetCustomTimestamp(timestamp int64)

SetCustomTimestamp sets a custom timestamp for this frame.

func (*VdoFrame) SetExtraInfo

func (f *VdoFrame) SetExtraInfo(extraInfo *VdoMap)

SetExtraInfo sets the extra info of this frame.

func (*VdoFrame) SetFrameType

func (f *VdoFrame) SetFrameType(frameType VdoFrameType)

SetFrameType sets the type of this frame.

func (*VdoFrame) SetHeaderSize

func (f *VdoFrame) SetHeaderSize(size int)

SetHeaderSize sets the header size of this frame, used for H26x frames.

func (*VdoFrame) SetIsLastBuffer

func (f *VdoFrame) SetIsLastBuffer(isLastBuffer bool)

SetIsLastBuffer marks this frame as the last buffer.

func (*VdoFrame) SetSequenceNbr

func (f *VdoFrame) SetSequenceNbr(seqNum uint)

SetSequenceNbr sets the sequence number of this frame.

func (*VdoFrame) SetSize

func (f *VdoFrame) SetSize(size uint)

SetSize sets the size of this frame.

func (*VdoFrame) SetTimestamp

func (f *VdoFrame) SetTimestamp(timestamp uint64)

SetTimestamp sets the timestamp of this frame.

func (*VdoFrame) Unmap

func (f *VdoFrame) Unmap()

Unmap unmaps the frame from current process memory.

func (*VdoFrame) Unref

func (b *VdoFrame) Unref()

Unref/Free the VdoFrame

type VdoFrameType

type VdoFrameType int

VdoRateControlPriority corresponds to the C enum VdoRateControlPriority.

const (
	VdoFrameTypeNone      VdoFrameType = C.VDO_FRAME_TYPE_NONE
	VdoFrameTypeH264SPS   VdoFrameType = C.VDO_FRAME_TYPE_H264_SPS
	VdoFrameTypeH264PPS   VdoFrameType = C.VDO_FRAME_TYPE_H264_PPS
	VdoFrameTypeH264SEI   VdoFrameType = C.VDO_FRAME_TYPE_H264_SEI
	VdoFrameTypeH264IDR   VdoFrameType = C.VDO_FRAME_TYPE_H264_IDR
	VdoFrameTypeH264I     VdoFrameType = C.VDO_FRAME_TYPE_H264_I
	VdoFrameTypeH264P     VdoFrameType = C.VDO_FRAME_TYPE_H264_P
	VdoFrameTypeH264B     VdoFrameType = C.VDO_FRAME_TYPE_H264_B
	VdoFrameTypeH265SPS   VdoFrameType = C.VDO_FRAME_TYPE_H265_SPS
	VdoFrameTypeH265PPS   VdoFrameType = C.VDO_FRAME_TYPE_H265_PPS
	VdoFrameTypeH265VPS   VdoFrameType = C.VDO_FRAME_TYPE_H265_VPS
	VdoFrameTypeH265SEI   VdoFrameType = C.VDO_FRAME_TYPE_H265_SEI
	VdoFrameTypeH265IDR   VdoFrameType = C.VDO_FRAME_TYPE_H265_IDR
	VdoFrameTypeH265I     VdoFrameType = C.VDO_FRAME_TYPE_H265_I
	VdoFrameTypeH265P     VdoFrameType = C.VDO_FRAME_TYPE_H265_P
	VdoFrameTypeH265B     VdoFrameType = C.VDO_FRAME_TYPE_H265_B
	VdoFrameTypeJPEG      VdoFrameType = C.VDO_FRAME_TYPE_JPEG
	VdoFrameTypeYUV       VdoFrameType = C.VDO_FRAME_TYPE_YUV
	VdoFrameTypeRAW       VdoFrameType = C.VDO_FRAME_TYPE_RAW
	VdoFrameTypeRGBA      VdoFrameType = C.VDO_FRAME_TYPE_RGBA
	VdoFrameTypeRGB       VdoFrameType = C.VDO_FRAME_TYPE_RGB
	VdoFrameTypePlanarRGB VdoFrameType = C.VDO_FRAME_TYPE_PLANAR_RGB
)

func (VdoFrameType) String

func (v VdoFrameType) String() string

type VdoH264Profile

type VdoH264Profile int

VdoH264Profile corresponds to the C enum VdoH264Profile.

const (
	VdoH264ProfileNone     VdoH264Profile = C.VDO_H264_PROFILE_NONE
	VdoH264ProfileBaseline VdoH264Profile = C.VDO_H264_PROFILE_BASELINE
	VdoH264ProfileMain     VdoH264Profile = C.VDO_H264_PROFILE_MAIN
	VdoH264ProfileHigh     VdoH264Profile = C.VDO_H264_PROFILE_HIGH
)

type VdoH265Profile

type VdoH265Profile int

VdoH265Profile corresponds to the C enum VdoH265Profile.

const (
	VdoH265ProfileNone   VdoH265Profile = C.VDO_H265_PROFILE_NONE
	VdoH265ProfileMain   VdoH265Profile = C.VDO_H265_PROFILE_MAIN
	VdoH265ProfileMain10 VdoH265Profile = C.VDO_H265_PROFILE_MAIN_10
)

type VdoIntent

type VdoIntent uint
const (
	VdoIntentNone     VdoIntent = 0
	VdoIntentControl  VdoIntent = 1
	VdoIntentMonitor  VdoIntent = 2
	VdoIntentConsume  VdoIntent = 4
	VdoIntentProduce  VdoIntent = 8
	VdoIntentDefault  VdoIntent = VdoIntentConsume | VdoIntentControl
	VdoIntentEventFD  VdoIntent = 16
	VdoIntentUniverse VdoIntent = ^VdoIntent(0)
)

type VdoMap

type VdoMap struct {
	Ptr *C.VdoMap
}

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/classVdoMap.html

func GetGlobalVdoChannelInfo

func GetGlobalVdoChannelInfo() (*VdoMap, error)

Get the info for this channel. This function is called in order to get a pointer to the info map for this channel. The returned pointer is a pointer to a newly allocated VdoMap owned by the caller of this function

https://axiscommunications.github.io/acap-documentation/docs/api/src/api/vdostream/html/vdo-channel_8h.html#ab364b357cef90100a312a14ff945b95d

func NewVdoMap

func NewVdoMap() *VdoMap

Creates a new VdoMap

func NewVdoMapFromC

func NewVdoMapFromC(ptr *C.VdoMap) *VdoMap

Creates a new VdoMap from C

func VideoStreamConfigToVdoMap

func VideoStreamConfigToVdoMap(cfg VideoSteamConfiguration) *VdoMap

VideoStreamConfigToVdoMap converts a VideoSteamConfiguration object into a VdoMap. This conversion allows the configuration to be applied to the video stream by translating high-level configuration options into the format expected by the streaming system.

func (*VdoMap) GetBoolean

func (m *VdoMap) GetBoolean(name string, defaultValue bool) bool

GetBoolean gets a bool value by name from VdoMap.

func (*VdoMap) GetByte

func (m *VdoMap) GetByte(name string, defaultValue byte) byte

GetByte gets a byte value by name from VdoMap.

func (*VdoMap) GetDouble

func (m *VdoMap) GetDouble(name string, defaultValue float64) float64

GetDouble gets a double value by name from VdoMap.

func (*VdoMap) GetInt16

func (m *VdoMap) GetInt16(name string, defaultValue int16) int16

GetInt16 gets a int16 value by name from VdoMap.

func (*VdoMap) GetInt32

func (m *VdoMap) GetInt32(name string, defaultValue int32) int32

GetInt32 gets a int32 value by name from VdoMap.

func (*VdoMap) GetInt64

func (m *VdoMap) GetInt64(name string, defaultValue int64) int64

GetInt64 gets a int64 value by name from VdoMap.

func (*VdoMap) GetString

func (m *VdoMap) GetString(name string, defaultValue string) string

GetString gets a string value by name from VdoMap.

func (*VdoMap) GetUint16

func (m *VdoMap) GetUint16(name string, defaultValue uint16) uint16

GetUint16 gets a uint16 value by name from VdoMap.

func (*VdoMap) GetUint32

func (m *VdoMap) GetUint32(name string, defaultValue uint32) uint32

GetUint32 gets a uint32 value by name from VdoMap.

func (*VdoMap) GetUint64

func (m *VdoMap) GetUint64(name string, defaultValue uint64) uint64

GetUint64 gets a uint64 value by name from VdoMap.

func (*VdoMap) SetBoolean

func (m *VdoMap) SetBoolean(name string, value bool)

Sets bool value in VdoMap

func (*VdoMap) SetByte

func (m *VdoMap) SetByte(name string, value byte)

SetByte value in a VdoMap

func (*VdoMap) SetDouble

func (m *VdoMap) SetDouble(name string, value float64)

SetDouble sets a double value by name in VdoMap.

func (*VdoMap) SetInt16

func (m *VdoMap) SetInt16(name string, value int16)

SetInt16 sets an int16 value by name in VdoMap.

func (*VdoMap) SetInt32

func (m *VdoMap) SetInt32(name string, value int32)

SetInt32 sets an int32 value by name in VdoMap.

func (*VdoMap) SetInt64

func (m *VdoMap) SetInt64(name string, value int64)

SetInt64 sets an int64 value by name in VdoMap.

func (*VdoMap) SetString

func (m *VdoMap) SetString(name string, value string)

SetString sets a string value by name in VdoMap.

func (*VdoMap) SetUint16

func (m *VdoMap) SetUint16(name string, value uint16)

SetUint16 sets a uint16 value by name in VdoMap.

func (*VdoMap) SetUint32

func (m *VdoMap) SetUint32(name string, value uint32)

SetUint32 sets a uint32 value by name in VdoMap.

func (*VdoMap) SetUint64

func (m *VdoMap) SetUint64(name string, value uint64)

SetUint64 sets a uint64 value by name in VdoMap.

type VdoMemChunk

type VdoMemChunk struct {
	Data     unsafe.Pointer // Pointer to the data
	DataSize uintptr        // Size of the data in bytes
}

VdoMemChunk represents a memory chunk with its data pointer and size.

type VdoOverlayAlign

type VdoOverlayAlign int
const (
	VdoOverlayAlignNone   VdoOverlayAlign = -1
	VdoOverlayAlignTop    VdoOverlayAlign = 0
	VdoOverlayAlignBottom VdoOverlayAlign = 1
)

type VdoOverlayColor

type VdoOverlayColor uint16
const (
	VdoOverlayColorTransparent VdoOverlayColor = 0x0000
	VdoOverlayColorBlack       VdoOverlayColor = 0xF000
	VdoOverlayColorWhite       VdoOverlayColor = 0xFFFF
)

type VdoOverlayTextSize

type VdoOverlayTextSize int
const (
	VdoOverlayTextSizeSmall  VdoOverlayTextSize = 16
	VdoOverlayTextSizeMedium VdoOverlayTextSize = 32
	VdoOverlayTextSizeLarge  VdoOverlayTextSize = 48
)

type VdoRateControlMode

type VdoRateControlMode int

VdoRateControlMode corresponds to the C enum VdoRateControlMode.

type VdoRateControlPriority

type VdoRateControlPriority int

VdoRateControlPriority corresponds to the C enum VdoRateControlPriority.

const (
	VdoRateControlPriorityNone          VdoRateControlPriority = C.VDO_RATE_CONTROL_PRIORITY_NONE
	VdoRateControlPriorityFramerate     VdoRateControlPriority = C.VDO_RATE_CONTROL_PRIORITY_FRAMERATE
	VdoRateControlPriorityQuality       VdoRateControlPriority = C.VDO_RATE_CONTROL_PRIORITY_QUALITY
	VdoRateControlPriorityFullFramerate VdoRateControlPriority = C.VDO_RATE_CONTROL_PRIORITY_FULL_FRAMERATE
)

type VdoRect

type VdoRect struct {
	Width  uint // Width of the rectangle
	Height uint // Height of the rectangle
	X      uint // X coordinate of the rectangle's origin
	Y      uint // Y coordinate of the rectangle's origin
}

VdoRect represents a rectangular area with width, height, and position (x, y).

type VdoResolution

type VdoResolution struct {
	Width  int
	Height int
}

VdoResolution represents the resolution of a video or an image.

func GetVdoChannelMaxResolution

func GetVdoChannelMaxResolution(video_channel int) (*VdoResolution, error)

Returns the higest resolution for a video channel Video channel, 0 is overview, 1, 2, ... are view areas.

func GetVdoChannelResolutions

func GetVdoChannelResolutions(video_channel int) ([]VdoResolution, error)

Returns a list of resolutions for the given video channel Video channel, 0 is overview, 1, 2, ... are view areas.

func (VdoResolution) RgbSize added in v1.0.2

func (r VdoResolution) RgbSize() int

type VdoStream

type VdoStream struct {
	Ptr *C.VdoStream
}

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html

func NewVideoStreamFromConfig

func NewVideoStreamFromConfig(stream_cfg VideoSteamConfiguration) (*VdoStream, error)

NewVideoStreamFromConfig creates and initializes a new video stream based on the provided configuration. It converts the configuration into a format understood by the underlying video streaming system and starts the stream.

func VdoChannelGetAll

func VdoChannelGetAll() ([]*VdoStream, error)

Gets all existing channels. Create new VdoChannel objects representing each existing channel and return those in a GList.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#ab1032730452f1617fd004f9aa46ded70

func VdoChannelGetFilterd

func VdoChannelGetFilterd(filter *VdoMap) ([]*VdoStream, error)

Gets all existing channels matching a filter. Create new VdoChannel objects representing existing channels matching a filter and return those in a VdoStream List.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-channel_8h.html#a045ce99305ee3e07ce2a243a6fd28861

func (*VdoStream) Attach

func (v *VdoStream) Attach(intent *VdoMap) error

Attach to a Stream. This function is intended to be used with vdo_stream_get, it is redundant to attach to a stream which was created by NewVdoStream. VDO_INTENT_CONTROL Grants start, stop, info, settings, keyframe VDO_INTENT_MONITOR Monitor events using g_signal VDO_INTENT_CONSUME The client intends to stream VDO_INTENT_PRODUCE The client intends to inject frames VDO_INTENT_DEFAULT Grants CONSUME and CONTROL VDO_INTENT_EVENTFD Monitor events using file descriptors VDO_INTENT_UNIVERSE Everything except VDO_INTENT_EVENTFD

vdoMap.SetUint32("intent", VdoIntentEventFD)

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#aba5b4264502272caae02a621f3bad63c

func (*VdoStream) BufferAlloc

func (v *VdoStream) BufferAlloc() (*VdoBuffer, error)

Allocates a new buffer for this stream. Invoke this function in order to allocate a new buffer for this video stream. The vdo service performs the actual memory allocation and owns the buffer. A handle to the allocated buffer is returned in the form of a VdoBuffer

Note:

This function is synchronous and will block until a response from the vdo service is received.
This function can only be invoked for non-encoded video streams.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a18ff54d35650a8fa4a00da2198b4b2d3 TODO: add opaque

func (*VdoStream) BufferEnqueue

func (v *VdoStream) BufferEnqueue(buffer *VdoBuffer) error

Enqueue a buffer for this video stream. Invoking this function equeues the specified VdoBuffer in the internal queue of this video stream in order to be subsequently filled with frame data.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a897b1e6d50e00aa8974511b4625cbad3

func (*VdoStream) BufferUnref

func (v *VdoStream) BufferUnref(buffer *VdoBuffer) error

Decreases the reference count for the specified buffer. The buffer is freed by the vdo service when the reference count reaches 0. Note:

This function is synchronous and will block until a response from the vdo service is received.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a5c13ae89ffee889aebf1a9b6c3bc3594

func (*VdoStream) ForceKeyFrame

func (v *VdoStream) ForceKeyFrame() error

Forces this video stream to insert a key frame. This function is invoked in order to force a key frame into a video stream. Invoking this functionon a video stream with a format that is not a video format (e.g. H.264 or H.265) will have no effect.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a32ba781b100c13c7b70e0f700bbce268

func (*VdoStream) GetBuffer

func (v *VdoStream) GetBuffer() (*VdoBuffer, error)

Fetches a VdoBuffer containing a frame. Stream global settings which control the behavior of this function: "socket.blocking" (default: TRUE) "socket.timeout_ms" The following errors are transient: VDO_ERROR_NO_DATA Recover by fetching the next buffer. The following errors are expected to occur during maintenance: VDO_ERROR_INTERFACE_DOWN Recover by waiting for the service to restart. Complete VdoStream reinitialization is necessary. All remaining errors are fatal: Complete VdoStream reinitialization is necessary.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a021f68451699a9ca04aa0e67d9b2917e

func (*VdoStream) GetEvent

func (v *VdoStream) GetEvent() (*VdoMap, error)

Fetches the next Event. See VdoStreamEvent for the list of possible events, the current event is returned in the VdoMap "event" field. The following errors are transient: VDO_ERROR_NO_EVENT The equivalent of EAGAIN, i.e. there's currently no event. The following errors are expected to occur during maintenance: VDO_ERROR_INTERFACE_DOWN Recover by waiting for the service to restart. Complete VdoStream reinitialization is necessary. All remaining errors are fatal: Complete VdoStream reinitialization is necessary.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#af416bd3ec1edf4055c554e0f78b7b9f9

func (*VdoStream) GetEventFd

func (v *VdoStream) GetEventFd() (int, error)

Returns a file descriptor for prioritized events. This requires VDO_INTENT_EVENTFD and is intended to be used together with the vdo_stream_get_event function.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#acbdc222c597329e543ba85f330526b12

func (*VdoStream) GetFd

func (v *VdoStream) GetFd() (int, error)

Returns a file descriptor representing the underlying socket connection. The file descriptor returned by this function represents the underlying socket based connection to the vdo service. The returned file descriptor can by used as an event source in an event loop to handle asynchronous I/O events.

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#a81faad176c49398f0a0b9826fb7c31f8

func (*VdoStream) SetFramerate

func (v *VdoStream) SetFramerate(framerate float64) error

Update the framerate for this video stream. This function is invoked in order to update the framerate of a video stream. For this API to be used, the stream needs one or more of the following stream settings to be applied before the stream is started: 1) Dynamic framerate is enabled (dynamic.framerate = TRUE) 2) Zipstream fps mode is set to dynamic (zip.fps_mode = 1)

https://axiscommunications.github.io/acap-documentation/docs/acap-sdk-version-3/api/src/api/vdostream/html/vdo-stream_8h.html#af43f6acfe327b99037ea1e046788e7b5

func (*VdoStream) Unref

func (v *VdoStream) Unref()

Unref/Free the VdoStream

type VdoStreamEvent

type VdoStreamEvent uint
const (
	VdoStreamEventNone      VdoStreamEvent = 0x00
	VdoStreamEventStarted   VdoStreamEvent = 0x01
	VdoStreamEventStopped   VdoStreamEvent = 0x02
	VdoStreamEventResource  VdoStreamEvent = 0x10
	VdoStreamEventQuotaSoft VdoStreamEvent = 0x11
	VdoStreamEventQuotaHard VdoStreamEvent = 0x12
	VdoStreamEventZipstream VdoStreamEvent = 0x20
	VdoStreamEventInvalid   VdoStreamEvent = ^VdoStreamEvent(0)
)

type VdoStreamTimestamp

type VdoStreamTimestamp uint
const (
	VdoTimestampNone                  VdoStreamTimestamp = 0
	VdoTimestampUTC                   VdoStreamTimestamp = 1
	VdoTimestampZipstream             VdoStreamTimestamp = 2
	VdoTimestampDiff                  VdoStreamTimestamp = 4
	VdoTimestampMonoCapture           VdoStreamTimestamp = 8
	VdoTimestampMonoServer            VdoStreamTimestamp = 16
	VdoTimestampMonoClient            VdoStreamTimestamp = 32
	VdoTimestampMonoClientServerDiff  VdoStreamTimestamp = VdoTimestampDiff | VdoTimestampMonoClient | VdoTimestampMonoServer
	VdoTimestampMonoClientCaptureDiff VdoStreamTimestamp = VdoTimestampDiff | VdoTimestampMonoClient | VdoTimestampMonoCapture
)

type VdoWdrMode

type VdoWdrMode int

VdoWdrMode corresponds to the C enum VdoWdrMode.

const (
	VdoWdrModeNone   VdoWdrMode = C.VDO_WDR_MODE_NONE
	VdoWdrModeLinear VdoWdrMode = C.VDO_WDR_MODE_LINEAR
	VdoWdrMode2X     VdoWdrMode = C.VDO_WDR_MODE_2X
	VdoWdrMode3X     VdoWdrMode = C.VDO_WDR_MODE_3X
	VdoWdrMode4X     VdoWdrMode = C.VDO_WDR_MODE_4X
	VdoWdrModeSensor VdoWdrMode = C.VDO_WDR_MODE_SENSOR
)

type VdoZipStreamProfile

type VdoZipStreamProfile int
const (
	VdoZipStreamProfileNone    VdoZipStreamProfile = -1
	VdoZipStreamProfileClassic VdoZipStreamProfile = 0
	VdoZipStreamProfileStorage VdoZipStreamProfile = 1
	VdoZipStreamProfileLive    VdoZipStreamProfile = 2
)

type VideoFrame

type VideoFrame struct {
	SequenceNbr   uint         // The sequence number of the frame.
	Timestamp     time.Time    // The timestamp when the frame was captured.
	Size          uint         // The size of the frame data in bytes.
	Data          []byte       // The raw data of the video frame
	Type          VdoFrameType // Type describes the frame type (e.g., I-frame, P-frame, B-frame).
	Error         error        // Error contains any error that occurred while processing the frame.
	ErrorExpected bool         // ErrorExpected indicates whether the error was expected on vdo maintance
	HeaderSize    int          // HeaderSize is the size of the frame header
}

VideoFrame represents a single frame of video data, including metadata such as the sequence number, timestamp, and size. It also includes information about the type of frame and any errors encountered.

func GetVideoFrame

func GetVideoFrame(vdo_stream *VdoStream) *VideoFrame

GetVideoFrame retrieves a video frame from a video stream. If an expected error occurs (e.g., for stream maintenance), the function returns a VideoFrame with the Error and ErrorExpected fields set. This function is recursive and will retry fetching a frame if a recoverable error occurs.

func NewVideoFrame

func NewVideoFrame(frame *VdoFrame, data []byte, header_size int) *VideoFrame

NewVideoFrame creates a new VideoFrame instance from a VdoFrame and its data. This function extracts relevant information from the VdoFrame, including the sequence number, timestamp, size, and frame type, and packages it into a VideoFrame structure.

func (*VideoFrame) HeaderData

func (f *VideoFrame) HeaderData() []byte

func (*VideoFrame) String

func (f *VideoFrame) String() string

String returns a string representation of the VideoFrame, including sequence number, timestamp, size, and frame type.

type VideoSteamConfiguration

type VideoSteamConfiguration struct {
	Format              *VdoFormat              //Video stream format as VdoFormat.
	BufferCount         *int                    // How many in-flight buffers are desired.
	BufferStrategy      *VdoBufferStrategy      // Buffering Strategy as VdoBufferStrategy.
	Input               *int                    // Video input, 1 ... inmax. 0 is invalid. No view areas.
	Channel             *int                    // Video channel, 0 is overview, 1, 2, ... are view areas.
	Width               *int                    // Video stream horizontal resolution.
	Height              *int                    // Video stream vertical resolution.
	Framerate           *int                    // Video stream vertical resolution.
	Compression         *int                    // Video stream compression, Axis standard range [0:100]
	Rotation            *StreamRotation         // Video stream rotation, normally [0,90,180,270].
	HorizontalFlip      *bool                   // Video stream horizontal flip (mirroring).
	VerticalFlip        *bool                   // Video stream vertical flip.
	Monochrome          *bool                   // Video stream monochrome encoding.
	DynamicGOP          *bool                   // Enable dynamic gop
	DynamicBitrate      *bool                   // Enable dynamic bitrate
	DynamicFramerate    *bool                   // Enable dynamic framerate
	DynamicCompression  *bool                   // Enable dynamic compression
	Qpi                 *uint32                 // QP value for I-frames.
	Qpp                 *uint32                 // QP value for P-frames.
	Bitrate             *uint32                 // Video stream bitrate (bps)
	RateControlMode     *VdoRateControlMode     // Bitrate control mode.
	RateControlPriority *VdoRateControlPriority // Bitrate control priority.
	GOPLength           *uint32                 // GOP length.
	// H.264 Specific Settings
	H264Profile *VdoH264Profile // H.265 profile as VdoH264Profile
	H265Profile *VdoH265Profile // H.264 profile as VdoH264Profile
	// Zipstream Specific Settings
	ZipStrength     *uint32              // Zipstream strength.
	ZipMaxGOPLength *uint32              // Zipstream maximum GOP length.
	ZipGOPMode      *ZipGopMode          // Zipstream GOP mode [0 = fixed, 1 = dynamic].
	ZipFPSMode      *ZipFPSMode          // Zipstream framerate control mode: [0 = fixed, 1 = dynamic].
	ZipSkipMode     *ZipSkipMode         // Zipstream frame skip mode: [0 = drop, 1 = empty].
	ZipMinFPSNum    *uint32              // Zipstream minimum framerate numerator.
	ZipMinFPSDen    *uint32              // Zipstream minimum framerate denominator.
	ZipProfile      *VdoZipStreamProfile // Zipstream profile.
	// ABR Specific Settings
	// The following ABR specific settings are supported with VDO_RATE_CONTROL_MODE_ABR.
	AbrTarget_bitrate *uint32 // Stream target bitrate (bps)
	AbrRetention_time *uint32 // Retention time in seconds
}

func (*VideoSteamConfiguration) GetChannel

func (vsc *VideoSteamConfiguration) GetChannel() int

GetChannel extracts the channel number from a VideoSteamConfiguration if it's set, otherwise returns a default value of 0. This method simplifies accessing the channel value, providing a safe way to handle nil pointers within the configuration.

func (*VideoSteamConfiguration) RgbFrameSize added in v1.0.2

func (vsc *VideoSteamConfiguration) RgbFrameSize() int

type ZipFPSMode

type ZipFPSMode int
const (
	ZipFPSModeFixed   ZipFPSMode = 0
	ZipFPSModeDynamic ZipFPSMode = 1
)

type ZipGopMode

type ZipGopMode int
const (
	ZipGOPModeFixed   ZipGopMode = 0
	ZipGOPModeDynamic ZipGopMode = 1
)

type ZipSkipMode

type ZipSkipMode int
const (
	ZipSkipModeDrop  ZipSkipMode = 0
	ZipSkipModeEmpty ZipSkipMode = 1
)

Jump to

Keyboard shortcuts

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