videostore

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package videostore contains the implementation of the video storage camera component.

Index

Constants

This section is empty.

Variables

View Source
var Model = resource.ModelNamespace("viam").WithFamily("video").WithModel("storage")

Model is the model for the video storage camera component.

Functions

This section is empty.

Types

type CodecType

type CodecType int

CodecType repreasents a codec.

const (
	// CodecTypeUnknown is an invalid type.
	CodecTypeUnknown CodecType = iota
	// CodecTypeH264 represents h264 codec.
	CodecTypeH264
	// CodecTypeH265 represents h265 codec.
	CodecTypeH265
)

func (CodecType) String

func (t CodecType) String() string

type Config

type Config struct {
	Name        string
	Type        SourceType
	Storage     StorageConfig
	Encoder     EncoderConfig
	FramePoller FramePollerConfig
}

Config configures a videostore.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if the Config is invalid.

type ContainerFormat added in v0.0.8

type ContainerFormat int

ContainerFormat specifies the output container format for concatenation.

const (
	// ContainerDefault is the default format (currently MP4 with faststart).
	ContainerDefault ContainerFormat = iota
	// ContainerMP4 produces standard MP4 with moov atom at the beginning for progressive playback.
	ContainerMP4
	// ContainerFMP4 produces fragmented MP4 with moof/mdat pairs for streaming.
	ContainerFMP4
)

func (ContainerFormat) String added in v0.0.8

func (c ContainerFormat) String() string

String returns the string representation of the container format.

type EncoderConfig

type EncoderConfig struct {
	Bitrate int
	Preset  string
}

EncoderConfig is the config for the video encoder.

func (EncoderConfig) Validate

func (c EncoderConfig) Validate() error

Validate returns an error if the EncoderConfig is invalid.

type FetchRequest

type FetchRequest struct {
	From      time.Time
	To        time.Time
	Container ContainerFormat
}

FetchRequest is the request to the Fetch method.

func (*FetchRequest) Validate

func (r *FetchRequest) Validate() error

Validate returns an error if the FetchRequest is invalid.

type FetchResponse

type FetchResponse struct {
	Video []byte
}

FetchResponse is the resonse to the Fetch method.

type FramePollerConfig

type FramePollerConfig struct {
	Camera    camera.Camera
	Framerate int
	YUYV      bool
}

FramePollerConfig is the config for the frame poller.

func (FramePollerConfig) Validate

func (c FramePollerConfig) Validate() error

Validate returns an error if the FramePollerConfig is invalid.

type RTPVideoStore

type RTPVideoStore interface {
	VideoStore
	Segmenter() *RawSegmenter
}

RTPVideoStore stores video derived from RTP packets and provides APIs to request the stored video.

func NewRTPVideoStore

func NewRTPVideoStore(ctx context.Context, config Config, logger logging.Logger) (RTPVideoStore, error)

NewRTPVideoStore returns a VideoStore that stores video it receives from the caller.

type RawSegmenter

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

RawSegmenter stores video in supported codecs to disk in segment video files

func (*RawSegmenter) Close

func (rs *RawSegmenter) Close() error

Close closes the segmenter and writes the trailer to prevent corruption when exiting early in the middle of a segment. Init may be called after Close

func (*RawSegmenter) Init

func (rs *RawSegmenter) Init(codec CodecType, width, height int) error

Init initializes the *RawSegmenter Close must be called to free the resources taken during Init Note: May write to disk

func (*RawSegmenter) WritePacket

func (rs *RawSegmenter) WritePacket(payload []byte, pts, dts int64, isIDR bool) error

WritePacket writes video data in the codec passed to Init to the current segment file. Can't be called before Init is called

type SaveRequest

type SaveRequest struct {
	From     time.Time
	To       time.Time
	Metadata string
	Async    bool
}

SaveRequest is the request to the Save method.

func (*SaveRequest) Validate

func (r *SaveRequest) Validate() error

Validate returns an error if the SaveRequest is invalid.

type SaveResponse

type SaveResponse struct {
	Filename string
}

SaveResponse is the response to the Save method.

type SourceType

type SourceType int

SourceType describes the type of video source.

const (
	// SourceTypeUnknown is an invalid type.
	SourceTypeUnknown SourceType = iota
	// SourceTypeFrame is a video store that creates a video from frames.
	SourceTypeFrame
	// SourceTypeRTP is a video store that creates a video from rtp packets.
	SourceTypeRTP
	// SourceTypeReadOnly is a video store that only reads already stored segment files.
	SourceTypeReadOnly
)

func (SourceType) String

func (t SourceType) String() string

type StorageConfig

type StorageConfig struct {
	SizeGB               int
	OutputFileNamePrefix string
	UploadPath           string
	StoragePath          string
}

StorageConfig is the config for storage.

func (StorageConfig) Validate

func (c StorageConfig) Validate() error

Validate returns an error if the StorageConfig is invalid.

type StorageState added in v0.0.8

type StorageState struct {
	VideoRanges              indexer.VideoRanges
	StorageLimitGB           int
	DeviceStorageRemainingGB float64
	StoragePath              string
}

StorageState summarizes the state of the stored video segments and storage config info.

type VideoStore

type VideoStore interface {
	Fetch(ctx context.Context, r *FetchRequest) (*FetchResponse, error)
	FetchStream(ctx context.Context, r *FetchRequest, emit func(video.Chunk) error) error
	Save(ctx context.Context, r *SaveRequest) (*SaveResponse, error)
	Close()
	GetStorageState(ctx context.Context) (*StorageState, error)
}

VideoStore stores video and provides APIs to request the stored video.

func NewFramePollingVideoStore

func NewFramePollingVideoStore(ctx context.Context, config Config, logger logging.Logger) (VideoStore, error)

NewFramePollingVideoStore returns a VideoStore that stores video it encoded from polling frames from a camera.Camera.

func NewReadOnlyVideoStore

func NewReadOnlyVideoStore(ctx context.Context, config Config, logger logging.Logger) (VideoStore, error)

NewReadOnlyVideoStore returns a VideoStore that can return stored video but doesn't create new video segements.

Directories

Path Synopsis
Package indexer manages metadata for video files stored on disk.
Package indexer manages metadata for video files stored on disk.
Package vsutils provides shared utility functions for video store.
Package vsutils provides shared utility functions for video store.

Jump to

Keyboard shortcuts

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