VideoPicture
pub struct VideoPicture<'a>
One BGRA picture the application composed, and when it belongs.
A borrowed buffer rather than an SDK frame, because an application that draws over the SDK's picture does not have one of those: it has its own surface, with its own row stride.
The C carries a data_size beside the pointer and checks it against
stride * height before reading anything. Here the slice is the
size, so the two cannot disagree, which is the one thing a caller
of the C entry point has to get right by hand.
VideoPicture — fields
bgra: &'a [u8]
BGRA8 pixels, row-major: byte 0 blue, 1 green, 2 red, 3 alpha.
The same layout crate::Camera::on_bgra_image delivers,
and the one Windows bitmaps, Avalonia's Bgra8888 and most GPU
uploads want, so the common case is a straight copy with no
channel work.
width: u32
Picture width in pixels. Must equal
VideoExportConfig::width.
A video stream has one frame size for its whole length and the encoder is opened once, so this cannot vary per frame. It is carried and validated rather than omitted, so a caller that changes its surface size mid-export is told rather than producing a file of sheared pictures.
height: u32
Picture height in pixels. Must equal
VideoExportConfig::height.
stride: u32
Row stride in bytes. 0 means width * 4, which is the tight
case.
This is the field that makes a caller-composed surface usable: a GPU readback, a Windows DIB and a Cairo surface are all padded to an alignment, and without it the stride is computed from the configured width and a padded buffer shears.
timestamp_us: Option<u64>
The time this picture belongs at, in microseconds from the start of the video.
This is what keeps a recording's gaps in the video. Neither
pacing the exporter offers fits an export: counting frames
closes the gaps in a recording, and
VideoExportConfig::pace_by_arrival follows the speed the
replay is being fed at. The recording's own time per frame is
the only one that keeps the video in step with what was
recorded, gaps included.
Quantised to the stream's time base, which is one
VideoExportConfig::frame_rate period per unit, so a gap
shorter than one frame period cannot be represented and closes.
Timestamps must increase: one that does not is advanced to the
next free slot rather than written, because a repeated timestamp
is not a slightly wrong duration; it is a stream a demuxer may
refuse.
None falls back to whatever
VideoExportConfig::pace_by_arrival selects.
VideoPicture — methods
pub fn new(bgra: &'a [u8], width: u32, height: u32) -> Self
A tightly packed picture at the pacing the configuration selects.
Set VideoPicture::stride for a padded surface and
VideoPicture::timestamp_us to carry a recording's own
timing.