pub struct V4l2M2mEncoder {Show 18 fields
fd: RawFd,
codec: Codec,
coded: u32,
width: i32,
height: i32,
row_bytes: usize,
bytesperline: usize,
output_size: usize,
output_map: *mut c_void,
capture: [(*mut c_void, usize); 2],
bitrate_bps: u32,
fps: f64,
omit_headers: bool,
color: Color,
fallback: Option<ColorSignal>,
written_sps: Option<(Vec<u8>, Vec<u8>)>,
decided: bool,
reorder: NoReorder,
}Fields§
§fd: RawFd§codec: Codec§coded: u32§width: i32§height: i32§row_bytes: usize§bytesperline: usize§output_size: usize§output_map: *mut c_void§capture: [(*mut c_void, usize); 2]§bitrate_bps: u32§fps: f64§omit_headers: bool§color: Color§fallback: Option<ColorSignal>What to declare when the device declares nothing, or None for a device off the record.
written_sps: Option<(Vec<u8>, Vec<u8>)>A sequence parameter set arrives with every key frame and is identical each time, so it is written once and matched by bytes after that.
decided: boolWhether the first access unit has settled what the stream says.
reorder: NoReorderThe reorder bound every H.264 set is held to. The session queues one frame and waits for its unit before the next, so pictures leave in the order they are shown whatever the device’s picture order count: a device that reordered would wait for a frame never queued.
Implementations§
Source§impl V4l2M2mEncoder
impl V4l2M2mEncoder
pub fn new( codec: Codec, settings: &CaptureSettings, rgba: bool, ) -> Result<Self, String>
Sourcefn release(&mut self)
fn release(&mut self)
Everything about the session that a refused STREAMON leaves behind, so the next attempt
starts on a node that carries none of it. The descriptor itself is reopened by the caller:
a device that refused a parameter answers ESRCH to every later call on that descriptor.
fn setup( &mut self, settings: &CaptureSettings, rgba: bool, ) -> Result<(), String>
fn call<T>(&self, request: u64, arg: &mut T, what: &str) -> Result<(), String>
Sourcefn set_control(&self, id: u32, value: i32, what: &str) -> Result<(), String>
fn set_control(&self, id: u32, value: i32, what: &str) -> Result<(), String>
A control this device refuses is a refusal of the session. It is not a warning to carry on
past: a rejected rate control mode leaves the node answering ESRCH to STREAMON until it
is closed, so a session that shrugged here would fail later and in a place that says
nothing about the cause.
fn set_frame_rate(&mut self, fps: f64) -> Result<(), String>
fn request_buffers(&self, type_: u32, count: u32) -> Result<(), String>
fn map_buffer( &self, type_: u32, index: u32, ) -> Result<(*mut c_void, usize), String>
fn queue(&self, type_: u32, index: u32, bytesused: u32) -> Result<(), String>
fn dequeue(&self, type_: u32) -> Result<(u32, usize), String>
fn stream(&self, request: u64, type_: u32, what: &str) -> Result<(), String>
Sourcefn wait_for_frame(&self) -> Result<(), String>
fn wait_for_frame(&self) -> Result<(), String>
Wait for the access unit of the frame just queued. The node is opened blocking, so this exists to bound the wait: a device that stopped answering has to become an error the ladder can act on, not a stream that never returns.
fn fill_output(&self, pixels: &[u8], stride: usize) -> Result<(), String>
pub fn codec(&self) -> Codec
Sourcefn frame_type(&self, bytes: &[u8]) -> u8
fn frame_type(&self, bytes: &[u8]) -> u8
The wire picture type of one access unit, read with the codec’s own syntax: an H.265 NAL header is two bytes where H.264’s is one, and VP8 and VP9 carry no NAL units at all.
Sourcepub fn is_fullcolor(&self) -> bool
pub fn is_fullcolor(&self) -> bool
The firmware converts to 4:2:0 and the encoder takes nothing else.
Sourcefn signal(&self) -> Option<ColorSignal>
fn signal(&self) -> Option<ColorSignal>
What the stream says about its color, once an access unit has settled it.
Sourcepub fn last_reference(&self) -> Reference
pub fn last_reference(&self) -> Reference
The kernel’s stateful interface names no reference and takes no invalidation.
pub fn invalidate_reference(&mut self, _frame_id: u16) -> bool
Sourcepub fn is_full_range(&self) -> bool
pub fn is_full_range(&self) -> bool
The range the stream declares, which is the device’s to decide: a session that says nothing is described as limited, since that is what a decoder given nothing assumes.
Sourcefn tag_sequence(&mut self, unit: &[u8]) -> Option<Vec<u8>>
fn tag_sequence(&mut self, unit: &[u8]) -> Option<Vec<u8>>
Learn what the first sequence parameter set says, and write one into every later set when the device said nothing and its conversion is on record; then hold every set to a reorder bound of zero. Only H.264 carries either here: an H.265 set names its own reordering, and VP8 and VP9 carry no parameter sets.
Sourcefn write_color(
&mut self,
original: &[u8],
signal: ColorSignal,
) -> Option<Vec<u8>>
fn write_color( &mut self, original: &[u8], signal: ColorSignal, ) -> Option<Vec<u8>>
original declaring signal, or None where the set cannot be written, in which case it
is left as it came: a stream that carries no color is watchable, and one carrying a set
built wrong is not.
Sourcepub fn reconfigure_rate(
&mut self,
settings: &CaptureSettings,
) -> Result<(), String>
pub fn reconfigure_rate( &mut self, settings: &CaptureSettings, ) -> Result<(), String>
Apply a live bitrate or frame rate change. Both are writable while streaming on this path, and the frame rate goes down with the bitrate: left behind, it would budget a new bitrate against an old rate.
pub fn encode_host( &mut self, pixels: &[u8], stride: usize, _rgba: bool, frame_number: u64, _qp: u32, force_idr: bool, ) -> Result<Vec<u8>, String>
Trait Implementations§
Source§impl Drop for V4l2M2mEncoder
impl Drop for V4l2M2mEncoder
impl Send for V4l2M2mEncoder
Auto Trait Implementations§
impl !Sync for V4l2M2mEncoder
impl Freeze for V4l2M2mEncoder
impl RefUnwindSafe for V4l2M2mEncoder
impl Unpin for V4l2M2mEncoder
impl UnsafeUnpin for V4l2M2mEncoder
impl UnwindSafe for V4l2M2mEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more