videostreams

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package videostreams provides a pub-sub system for running video stream processing pipelines on-demand.

Index

Constants

View Source
const (
	MethodPub   = pubsub.MethodPub
	MethodSub   = pubsub.MethodSub
	MethodUnsub = pubsub.MethodUnsub
)
View Source
const ChannelName = "Video::StreamsChannel"

ChannelName is the name of the Action Cable channel for Video Streams.

View Source
const Nop = ""

Variables

View Source
var LineHeight = fontFace.Metrics().Height.Round()

Functions

func AddAnnotationPadding added in v0.2.4

func AddAnnotationPadding(source image.Image, topLines, bottomLines int) (output draw.Image)

func AddLabel

func AddLabel(im draw.Image, label string, co color.Color, x, y int)

func AnnotateTop added in v0.2.4

func AnnotateTop(im draw.Image, annotations string, lines int)

func CopyRGBA added in v0.2.4

func CopyRGBA(im image.Image) draw.Image

func EmptyHandler

func EmptyHandler(c *Context) error

func NewChannelFactory added in v0.3.0

func NewChannelFactory(
	b *Broker, sessionID string, logger pubsub.Logger, checkers ...actioncable.IdentifierChecker,
) actioncable.ChannelFactory

NewChannelFactory creates an actioncable.ChannelFactory for Turbo Streams to create channels for different Video Streams streams as needed.

func ResizeToHeight added in v0.2.4

func ResizeToHeight(im image.Image, height int) draw.Image

Types

type AnnotationMetadata added in v0.2.4

type AnnotationMetadata struct {
	Width       int
	Height      int
	Timestamp   time.Time
	JPEGQuality int

	FPSCount  int64
	FPSPeriod float32
}

func (AnnotationMetadata) String added in v0.2.4

func (m AnnotationMetadata) String() string

func (AnnotationMetadata) WithFrameData added in v0.2.4

func (m AnnotationMetadata) WithFrameData(f *ImageFrame) AnnotationMetadata

type BroadcastReceiver

type BroadcastReceiver func(ctx context.Context, frames []Frame) error

type Broker

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

func NewBroker

func NewBroker(logger pubsub.Logger) *Broker

func (*Broker) Hub added in v0.3.0

func (b *Broker) Hub() *Hub

func (*Broker) PUB

func (b *Broker) PUB(topic string, h HandlerFunc, m ...MiddlewareFunc) *Route

func (*Broker) SUB

func (b *Broker) SUB(topic string, h HandlerFunc, m ...MiddlewareFunc) *Route

func (*Broker) Serve

func (b *Broker) Serve(ctx context.Context) error

func (*Broker) Subscribe

func (b *Broker) Subscribe(ctx context.Context, topic string) <-chan Frame

func (*Broker) UNSUB

func (b *Broker) UNSUB(topic string, h HandlerFunc, m ...MiddlewareFunc) *Route

func (*Broker) Use

func (b *Broker) Use(middleware ...MiddlewareFunc)

type Channel added in v0.3.0

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

Channel represents an Action Cable channel for a Video Streams stream.

func NewChannel added in v0.3.0

func NewChannel(
	identifier string, h *pubsub.Hub[[]Frame], subscriber subscriber, sessionID string,
	checkers []actioncable.IdentifierChecker, logger pubsub.Logger,
) (*Channel, error)

NewChannel checks the identifier with the specified checkers and returns a new Channel instance.

func (*Channel) Perform added in v0.3.0

func (c *Channel) Perform(data string) error

Perform handles an Action Cable action command from the client.

func (*Channel) Subscribe added in v0.3.0

func (c *Channel) Subscribe(ctx context.Context, sub *actioncable.Subscription) error

Subscribe handles an Action Cable subscribe command from the client with the provided actioncable.Subscription.

type Context

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

type Frame

type Frame interface {
	AsImageFrame() (*ImageFrame, error)
	AsJPEGFrame() (*JPEGFrame, error)
	Error() error
}

func NewErrorFrame

func NewErrorFrame(err error) Frame

type HandlerFunc

type HandlerFunc = pubsub.HandlerFunc[*Context]

type Hub

type Hub = pubsub.Hub[[]Frame]

type ImageFrame

type ImageFrame struct {
	Im   image.Image
	Meta *Metadata
	Err  error
}

func (*ImageFrame) AsImageFrame added in v0.2.4

func (f *ImageFrame) AsImageFrame() (*ImageFrame, error)

func (*ImageFrame) AsJPEGFrame added in v0.3.0

func (f *ImageFrame) AsJPEGFrame() (*JPEGFrame, error)

func (*ImageFrame) Error

func (f *ImageFrame) Error() error

func (*ImageFrame) WithAnnotation added in v0.2.4

func (f *ImageFrame) WithAnnotation(annotations string, lines int) *ImageFrame

func (*ImageFrame) WithResizeToHeight added in v0.2.4

func (f *ImageFrame) WithResizeToHeight(height int) *ImageFrame

type JPEGFrame added in v0.3.0

type JPEGFrame struct {
	Im   []byte
	Meta *Metadata
	Err  error
}

func (*JPEGFrame) AsImageFrame added in v0.3.0

func (f *JPEGFrame) AsImageFrame() (*ImageFrame, error)

func (*JPEGFrame) AsJPEGFrame added in v0.3.0

func (f *JPEGFrame) AsJPEGFrame() (*JPEGFrame, error)

func (*JPEGFrame) Error added in v0.3.0

func (f *JPEGFrame) Error() error

type Metadata

type Metadata struct {
	FromSource  map[string][]string
	ReceiveTime time.Time
	Operations  *OpChain
	Settings    Settings
}

func (*Metadata) WithOp added in v0.2.4

func (m *Metadata) WithOp(op Operation) *Metadata

func (*Metadata) WithSettings added in v0.2.4

func (m *Metadata) WithSettings(settings Settings) *Metadata

type MiddlewareFunc

type MiddlewareFunc = pubsub.MiddlewareFunc[*Context]

type OpChain added in v0.2.4

type OpChain struct {
	Op Operation
	// contains filtered or unexported fields
}

func (*OpChain) Linearization added in v0.2.4

func (o *OpChain) Linearization() []Operation

func (*OpChain) With added in v0.2.4

func (o *OpChain) With(op Operation) *OpChain

type Operation added in v0.2.4

type Operation string

func Operationf added in v0.2.4

func Operationf(formatString string, params ...interface{}) Operation

type Route

type Route = pubsub.Route

type Router

type Router = pubsub.Router[*Context]

type Settings added in v0.2.4

type Settings struct {
	JPEGEncodeQuality int
}

Jump to

Keyboard shortcuts

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