Which media formats bb_camera will carry: raw pixels, and nothing else.
BB.Camera.Hub keeps exactly one frame per camera and drops anything staler.
That policy is lossless for frames that stand alone and destructive for
frames that reference earlier ones, so the hub only carries frames that
stand alone. It goes further than that and only carries raw frames: a
driver decodes whatever its device produces - MJPEG, H.264, anything - before
handing a frame over. Every consumer then gets pixels it can use directly,
rather than each one decoding the same frame for itself, and a codec whose
frames depend on each other is the driver's problem rather than the hub's.
A format is {:raw, pixel_format}, where pixel_format is one of
Membrane.RawVideo's - :I420, :NV12, :YUY2, :RGB and so on - so a
frame can be handed to a Membrane pipeline without translating anything.
Packing
A raw frame's data is tightly packed: planes laid end to end in their
conventional order, rows with no padding between them. Its size is exactly
Membrane.RawVideo.frame_size/3 for its format and dimensions. Hardware that
pads rows to an alignment has to have that padding stripped by its driver.
Summary
Functions
Check a camera's format against what a caller asserted it would be.
The size in bytes of one frame in format at width x height, checking
along the way that this package will carry it.
Whether every frame in this format decodes without reference to any other.
Types
@type pixel_format() :: Membrane.RawVideo.pixel_format()
@type t() :: {:raw, pixel_format()}
Functions
@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.
@spec frame_size(term(), pos_integer(), pos_integer()) :: {:ok, pos_integer()} | {:error, BB.Error.Invalid.Camera.UnsupportedFormat.t()}
The size in bytes of one frame in format at width x height, checking
along the way that this package will carry it.
Returns {:error, %UnsupportedFormat{}} with a reason of:
:encoded- anything other than{:raw, pixel_format}. Decode it in the driver.:unknown_pixel_format- a raw formatMembrane.RawVideodoesn't name.:invalid_dimensions- dimensions the pixel format can't take, such as an odd width for chroma-subsampled:I420.
Whether every frame in this format decodes without reference to any other.
True of every raw format, and of nothing this package carries besides.