Skip to main content

ScatterFrame

Struct ScatterFrame 

Source
pub struct ScatterFrame<F: PacketFormat> { /* private fields */ }
Expand description

A sendable compressed frame held in ordered blocks, without joining them.

The first block holds the complete 44-byte envelope header for H.264, HEVC or AAC, or the first four bytes for SpeedHQ. Opus has no header.

§Examples

use grafton_ndi::advanced::{
    EnvelopeCodec, PacketEnvelope, ScatterFrame, VideoCodec, VideoPacketFormat,
};

let packet =
    PacketEnvelope::encode(EnvelopeCodec::H264, 0, 0, true, &[0x65; 64], &[0x67; 8])?;
let (header, rest) = packet.split_at(44);
let frame = ScatterFrame::new(
    VideoPacketFormat::new(VideoCodec::H264, 1280, 720)?,
    vec![header.to_vec(), rest.to_vec()],
)?;
assert_eq!(frame.total_bytes(), packet.len());

Implementations§

Source§

impl<F: PacketFormat> ScatterFrame<F>

Source

pub fn timecode(&self) -> Timecode

The timecode: crate::Timecode::SYNTHESIZE on a frame built for sending without an explicit timecode.

Source

pub fn set_timecode(&mut self, timecode: Timecode)

Replace the frame’s timecode.

Source

pub fn metadata(&self) -> Option<&str>

The per-frame metadata, if any. Unreadable received text is omitted.

Source

pub fn metadata_status(&self) -> FrameMetadataStatus

Cached metadata presence or the reason unreadable text was withheld.

Source

pub fn set_metadata( &mut self, metadata: impl Into<String>, ) -> Result<(), Rejected<String>>

Replace frame metadata. Use Self::clear_metadata to remove it.

Invalid replacement text leaves the existing metadata unchanged.

§Errors

Returns the unchanged text in crate::Rejected, with crate::Error::InvalidCString for an interior NUL, or crate::Error::InvalidFrame when the emitted C string would exceed the metadata size cap. NulError retains only the prefix through the first NUL; crate::Rejected::into_inner returns all text.

Source

pub fn clear_metadata(&mut self)

Remove the frame metadata.

Source

pub fn new( format: F, blocks: Vec<Vec<u8>>, ) -> Result<Self, Rejected<Vec<Vec<u8>>>>

Take ownership of one frame’s blocks, in order.

§Errors

Returns the original blocks with Error::InvalidFrame if the list is empty or exceeds MAX_SCATTER_BLOCKS, a block is empty, the frame exceeds MAX_PACKET_BYTES, or the packet is not sendable in this format.

Source

pub fn format(&self) -> F

The packet’s codec and media format.

Source

pub fn blocks(&self) -> impl ExactSizeIterator<Item = &[u8]>

The blocks, in order.

Source

pub fn into_blocks(self) -> Vec<Vec<u8>>

Recover each original block, preserving order, allocation and capacity. The SDK’s writes remain in those blocks.

Source

pub fn total_bytes(&self) -> usize

The combined size of the blocks, in bytes.

Source

pub fn into_contiguous_copy(self) -> CompressedFrame<F>

Join the blocks into one newly allocated contiguous frame.

Trait Implementations§

Source§

impl<F: Clone + PacketFormat> Clone for ScatterFrame<F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: PacketFormat> Debug for ScatterFrame<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ScatterFrame<VideoPacketFormat>> for QueuedVideoFrame

Source§

fn from(frame: ScatterFrame<VideoPacketFormat>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<F> Freeze for ScatterFrame<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for ScatterFrame<F>
where F: RefUnwindSafe,

§

impl<F> Send for ScatterFrame<F>

§

impl<F> Sync for ScatterFrame<F>

§

impl<F> Unpin for ScatterFrame<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for ScatterFrame<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for ScatterFrame<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.