pub struct WasmStreamingEncoder { /* private fields */ }Expand description
Encodes samples frame-by-frame as they arrive, returning encoded frames ready for transmission. Use this for low-latency streaming encoding where you push samples and pull frames.
Implementations§
Source§impl WasmStreamingEncoder
impl WasmStreamingEncoder
Sourcepub fn with_compression(self, level: u8) -> Self
pub fn with_compression(self, level: u8) -> Self
Sourcepub fn next_frame(&mut self) -> JsValue
pub fn next_frame(&mut self) -> JsValue
Get the next encoded frame if available
Returns an object with: index, timestamp_ms, data (Uint8Array), samples Returns null if no frames are ready yet.
§Returns
Encoded frame object or null
Sourcepub fn pending_samples(&self) -> usize
pub fn pending_samples(&self) -> usize
Sourcepub fn pending_frames(&self) -> usize
pub fn pending_frames(&self) -> usize
Sourcepub fn flush(&mut self) -> Result<(), JsValue>
pub fn flush(&mut self) -> Result<(), JsValue>
Flush remaining samples and finalize encoding
Call this when done pushing samples. Encodes any remaining partial frame. After this, call finalize() to get the complete flo file.
§Returns
Error if encoding fails
Sourcepub fn finalize(
&mut self,
metadata: Option<Vec<u8>>,
) -> Result<Vec<u8>, JsValue>
pub fn finalize( &mut self, metadata: Option<Vec<u8>>, ) -> Result<Vec<u8>, JsValue>
Build a complete flo file from all accumulated frames
Call flush() first, then this method to generate the complete file. The file will contain all encoded frames with proper table-of-contents.
§Arguments
metadata- Optional metadata bytes (MessagePack encoded, use create_metadata())
§Returns
Complete flo file as byte array
Trait Implementations§
Source§impl Default for WasmStreamingEncoder
Available on crate feature wasm only.
impl Default for WasmStreamingEncoder
wasm only.Source§impl From<WasmStreamingEncoder> for JsValue
impl From<WasmStreamingEncoder> for JsValue
Source§fn from(value: WasmStreamingEncoder) -> Self
fn from(value: WasmStreamingEncoder) -> Self
Source§impl FromWasmAbi for WasmStreamingEncoder
impl FromWasmAbi for WasmStreamingEncoder
Source§impl IntoWasmAbi for WasmStreamingEncoder
impl IntoWasmAbi for WasmStreamingEncoder
Source§impl LongRefFromWasmAbi for WasmStreamingEncoder
impl LongRefFromWasmAbi for WasmStreamingEncoder
Source§type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmStreamingEncoder>
type Anchor = RcRef<WasmStreamingEncoder>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl RefFromWasmAbi for WasmStreamingEncoder
impl RefFromWasmAbi for WasmStreamingEncoder
Source§type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
Self are recovered from.Source§type Anchor = RcRef<WasmStreamingEncoder>
type Anchor = RcRef<WasmStreamingEncoder>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WasmStreamingEncoder
impl RefMutFromWasmAbi for WasmStreamingEncoder
Source§type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
type Abi = WasmPtr<WasmRefCell<WasmStreamingEncoder>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmStreamingEncoder>
type Anchor = RcRefMut<WasmStreamingEncoder>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for WasmStreamingEncoder
impl SupportsInstanceProperty for WasmStreamingEncoder
impl SupportsStaticProperty for WasmStreamingEncoder
Source§impl VectorFromWasmAbi for WasmStreamingEncoder
impl VectorFromWasmAbi for WasmStreamingEncoder
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmStreamingEncoder]>
Source§impl VectorIntoWasmAbi for WasmStreamingEncoder
impl VectorIntoWasmAbi for WasmStreamingEncoder
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmStreamingEncoder]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmStreamingEncoder
impl WasmDescribeVector for WasmStreamingEncoder
Auto Trait Implementations§
impl Freeze for WasmStreamingEncoder
impl RefUnwindSafe for WasmStreamingEncoder
impl Send for WasmStreamingEncoder
impl Sync for WasmStreamingEncoder
impl Unpin for WasmStreamingEncoder
impl UnsafeUnpin for WasmStreamingEncoder
impl UnwindSafe for WasmStreamingEncoder
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
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.