Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ScalerNearestNeighbor = Scaler(draw.NearestNeighbor) ScalerApproxBiLinear = Scaler(draw.ApproxBiLinear) ScalerBiLinear = Scaler(draw.BiLinear) ScalerCatmullRom = Scaler(draw.CatmullRom) )
List of scaling algorithms
var ( // ScalerFastNearestNeighbor is a CGO version of NearestNeighbor scaler. // This is roughly 4-times faster than draw.NearestNeighbor. ScalerFastNearestNeighbor = Scaler(&FastNearestNeighbor{}) // ScalerFastBoxSampling is a CGO implementation of BoxSampling scaler. // This is heavyer than NearestNeighbor but keeps detail on down scaling. ScalerFastBoxSampling = Scaler(&FastBoxSampling{}) )
List of scaling algorithms
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Broadcaster is a specialized video broadcaster.
func NewBroadcaster ¶
func NewBroadcaster(source Reader, config *BroadcasterConfig) *Broadcaster
NewBroadcaster creates a new broadcaster. Source is expected to drop frames when any of the readers is slower than the source.
func (*Broadcaster) NewReader ¶
func (broadcaster *Broadcaster) NewReader(copyFrame bool) Reader
NewReader creates a new reader. Each reader will retrieve the same data from the source. copyFn is used to copy the data from the source to individual readers. Broadcaster uses a small ring buffer, this means that slow readers might miss some data if they're really late and the data is no longer in the ring buffer.
func (*Broadcaster) ReplaceSource ¶
func (broadcaster *Broadcaster) ReplaceSource(source Reader) error
ReplaceSource replaces the underlying source. This operation is thread safe.
func (*Broadcaster) Source ¶
func (broadcaster *Broadcaster) Source() Reader
Source retrieves the underlying source. This operation is thread safe.
type BroadcasterConfig ¶
type BroadcasterConfig struct {
Core *io.BroadcasterConfig
}
type FastBoxSampling ¶
type FastBoxSampling struct { }
FastBoxSampling is a CGO version of Box sampling scaler.
type FastNearestNeighbor ¶
type FastNearestNeighbor struct { }
FastNearestNeighbor is a CGO version of NearestNeighbor scaler.
type FrameBuffer ¶
type FrameBuffer struct {
// contains filtered or unexported fields
}
FrameBuffer is a buffer that can store any image format.
func NewFrameBuffer ¶
func NewFrameBuffer(initialSize int) *FrameBuffer
NewFrameBuffer creates a new FrameBuffer instance and initialize internal buffer with initialSize
func (*FrameBuffer) Load ¶
func (buff *FrameBuffer) Load() image.Image
Load loads the current owned image
func (*FrameBuffer) StoreCopy ¶
func (buff *FrameBuffer) StoreCopy(src image.Image)
StoreCopy makes a copy of src and store its copy. StoreCopy will reuse as much memory as it can from the previous copies. For example, if StoreCopy is given an image that has the same resolution and format from the previous call, StoreCopy will not allocate extra memory and only copy the content from src to the previous buffer.
type Reader ¶
type Reader interface { // Read reads data from the source. The caller is responsible to release the memory that's associated // with data by calling the given release function. When err is not nil, the caller MUST NOT call release // as data is going to be nil (no memory was given). Otherwise, the caller SHOULD call release after // using the data. The caller is NOT REQUIRED to call release, as this is only a part of memory management // optimization. If release is not called, the source is forced to allocate a new memory, which also means // there will be new allocations during streaming, and old unused memory will become garbage. As a consequence, // these garbage will put a lot of pressure to the garbage collector and makes it to run more often and finish // slower as the heap memory usage increases and more garbage to collect. Read() (img image.Image, release func(), err error) }
type ReaderFunc ¶
type TransformFunc ¶
TransformFunc produces a new Reader that will produces a transformed video
func DetectChanges ¶
func DetectChanges(interval time.Duration, fpsDiffTolerance float64, onChange func(prop.Media)) TransformFunc
DetectChanges will detect frame and video property changes. For video property detection, since it's time related, interval will be used to determine the sample rate.
func Merge ¶
func Merge(transforms ...TransformFunc) TransformFunc
Merge merges transforms and produces a new TransformFunc that will execute transforms in order
func Scale ¶
func Scale(width, height int, scaler Scaler) TransformFunc
Scale returns video scaling transform. Setting scaler=nil to use default scaler. (ScalerNearestNeighbor) Negative width or height value will keep the aspect ratio of incoming image.
Note: computation cost to scale YCbCr format is 10 times higher than RGB due to the implementation in x/image/draw package.
func Throttle ¶
func Throttle(rate float32) TransformFunc
Throttle returns video throttling transform. This transform drops some of the incoming frames to achieve given framerate in fps.