Skip to main content

PgsParser

Struct PgsParser 

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

PGS subtitle parser and renderer.

Implementations§

Source§

impl PgsParser

Source

pub fn new() -> Self

Create a new PGS parser.

Source

pub fn parse(&mut self, data: &[u8]) -> usize

Parse a PGS file from binary data. Returns the number of display sets parsed.

Source

pub fn count(&self) -> usize

Get the number of display sets.

Source

pub fn screen_width(&self) -> u16

Get the presentation width for this subtitle track.

Source

pub fn screen_height(&self) -> u16

Get the presentation height for this subtitle track.

Source

pub fn get_timestamps(&self) -> Vec<f64>

Get all timestamps in milliseconds.

Source

pub fn find_index_at_timestamp(&self, time_ms: f64) -> i32

Find the display set index for a given timestamp in milliseconds.

Source

pub fn get_cue_start_time(&self, index: usize) -> f64

Get the cue start time in milliseconds.

Source

pub fn get_cue_end_time(&self, index: usize) -> f64

Get the cue end time in milliseconds.

Source

pub fn get_cue_composition_count(&self, index: usize) -> u32

Get the number of composition objects in a cue.

Source

pub fn get_cue_palette_id(&self, index: usize) -> i32

Get the cue palette ID.

Source

pub fn get_cue_composition_state(&self, index: usize) -> i32

Get the cue composition state.

Source

pub fn render_at_index(&mut self, index: usize) -> Option<SubtitleFrame>

Render subtitle at the given index and return RGBA data. Returns null if index is invalid or no subtitle data.

Source

pub fn last_render_issue(&self) -> String

Get the last non-fatal render issue for diagnostics.

Source

pub fn clear_cache(&mut self)

Clear the internal cache.

Trait Implementations§

Source§

impl Default for PgsParser

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.