BB.Camera.Format (bb_camera v0.1.1)

Copy Markdown View Source

Which media formats bb_camera will carry, and why it refuses the rest.

BB.Camera.Hub keeps exactly one frame per camera and drops anything staler. That policy is lossless for formats whose frames decode independently, and destructive for formats whose frames reference earlier ones. So the set of formats this package carries is exactly the set where dropping is safe.

Today that set is :jpeg - a stream of complete JPEG images, what the world calls MJPEG. Raw pixel buffers would also qualify and are simply not implemented yet; they are rejected as :not_implemented rather than :interframe, because the distinction matters to anyone deciding whether to add one.

Interframe codecs are refused outright. There is no mode in which this package carries H.264 and drops frames, because the result would decode to garbage without anything in the pipeline noticing.

Summary

Functions

Check a camera's format against what a caller asserted it would be.

Whether every frame in this format decodes without reference to any other.

The formats this package carries.

Check a format is one this package will carry.

Types

t()

@type t() :: :jpeg

Functions

assert(format, format)

@spec assert(t(), term()) ::
  :ok | {:error, BB.Error.Invalid.Camera.UnsupportedFormat.t()}

Check a camera's format against what a caller asserted it would be.

nil asserts nothing.

independent_frames?(format)

@spec independent_frames?(term()) :: boolean()

Whether every frame in this format decodes without reference to any other.

This is the predicate the hub's drop-the-stale-frame policy is safe under, and therefore the predicate format support is gated on.

supported()

@spec supported() :: [t()]

The formats this package carries.

validate(format)

@spec validate(term()) ::
  {:ok, t()} | {:error, BB.Error.Invalid.Camera.UnsupportedFormat.t()}

Check a format is one this package will carry.

Returns {:error, %UnsupportedFormat{reason: :interframe}} for codecs whose frames depend on each other, and :not_implemented for anything else.