Skip to main content

VideoPacketFormat

Struct VideoPacketFormat 

Source
pub struct VideoPacketFormat { /* private fields */ }
Expand description

The codec, geometry and timing of compressed video, independent of any one frame’s bytes.

§Examples

use grafton_ndi::{
    advanced::{VideoCodec, VideoPacketFormat},
    FrameRate, StreamTier,
};

let format = VideoPacketFormat::new(VideoCodec::Hevc, 1920, 1080)?
    .with_frame_rate(FrameRate::new(60_000, 1001)?)
    .with_tier(StreamTier::Program);
assert_eq!(format.frame_rate(), FrameRate::new(60_000, 1001)?);
assert!(VideoPacketFormat::new(VideoCodec::Hevc, 0, 1080).is_err());

Implementations§

Source§

impl VideoPacketFormat

Source

pub fn new(codec: VideoCodec, width: u32, height: u32) -> Result<Self>

A progressive program-tier format at 60 frames per second with square pixels. Adjust it with the with_* methods.

§Errors

Error::InvalidInput unless both dimensions are in 1..=i32::MAX, the range the SDK can carry.

Source

pub fn with_frame_rate(self, frame_rate: FrameRate) -> Self

The same format at frame_rate.

Source

pub fn with_picture_aspect_ratio(self, ratio: PictureAspectRatio) -> Self

The same format with the validated displayed picture aspect ratio. PictureAspectRatio::SQUARE_PIXELS asks the SDK to derive it from the pixel dimensions.

Source

pub fn with_tier(self, tier: StreamTier) -> Self

The same format on the program or preview stream.

Source

pub fn with_scan_type(self, scan_type: ScanType) -> Self

The same format with scan type scan_type.

Source

pub fn with_protected(self, protected: bool) -> Self

The same format, marked as a protected stream or not.

Source

pub fn codec(self) -> VideoCodec

The codec.

Source

pub fn width(self) -> u32

Width in pixels.

Source

pub fn height(self) -> u32

Height in pixels.

Source

pub fn frame_rate(self) -> FrameRate

The frame rate.

Source

pub fn picture_aspect_ratio(self) -> PictureAspectRatio

The picture aspect ratio; 0.0 means square pixels.

Source

pub fn tier(self) -> StreamTier

The stream this format belongs to.

Source

pub fn scan_type(self) -> ScanType

The scan type.

Source

pub fn is_protected(self) -> bool

Whether the stream is protected.

Trait Implementations§

Source§

impl Clone for VideoPacketFormat

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 Copy for VideoPacketFormat

Source§

impl Debug for VideoPacketFormat

Source§

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

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

impl Eq for VideoPacketFormat

Source§

impl Hash for VideoPacketFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PacketFormat for VideoPacketFormat

Source§

impl PartialEq for VideoPacketFormat

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for VideoPacketFormat

Auto Trait Implementations§

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.