pub struct Window {Show 31 fields
pub state: WindowState,
pub priority: u8,
pub anchor_point: AnchorPoint,
pub anchor_vertical: u8,
pub anchor_horizontal: u8,
pub relative_position: bool,
pub row_count: u8,
pub column_count: u8,
pub row_lock: bool,
pub column_lock: bool,
pub window_style: u8,
pub pen_style: u8,
pub justify: Justify,
pub print_direction: PrintDirection,
pub scroll_direction: ScrollDirection,
pub word_wrap: bool,
pub fill_color: Color,
pub fill_opacity: Opacity,
pub border_color: Color,
pub border_type: EdgeType,
pub pen_size: PenSize,
pub pen_offset: PenOffset,
pub font_style: FontStyle,
pub italics: bool,
pub underline: bool,
pub edge_type: EdgeType,
pub edge_color: Color,
pub fg_color: Color,
pub fg_opacity: Opacity,
pub bg_color: Color,
pub bg_opacity: Opacity,
/* private fields */
}decode only.Expand description
A decoded CEA-708 caption window (§8.4 window model).
Holds the window attributes set by DefineWindow / SetWindowAttributes,
the pen attributes set by SetPenAttributes / SetPenColor, and the painted
text grid. Only created when a DefineWindow for its ID is received.
Fields§
§state: WindowStateWhether the window is currently displayed.
priority: u8Window priority, 0 (highest) – 7.
anchor_point: AnchorPointAnchor point (which corner/edge/centre the anchor coordinates refer to).
anchor_vertical: u8Anchor vertical coordinate.
anchor_horizontal: u8Anchor horizontal coordinate.
relative_position: booltrue if the anchor coordinates are relative (percent).
row_count: u8Row count (virtual rows; = rc + 1).
column_count: u8Column count (virtual cols; = cc + 1).
row_lock: boolRow lock.
column_lock: boolColumn lock.
window_style: u8Window-style preset ID (0–7) requested in the last DefineWindow.
pen_style: u8Pen-style preset ID (0–7) requested in the last DefineWindow.
justify: JustifyJustification.
print_direction: PrintDirectionPrint direction.
scroll_direction: ScrollDirectionScroll direction.
word_wrap: boolWord wrap.
fill_color: ColorWindow fill colour.
fill_opacity: OpacityWindow fill opacity.
border_color: ColorBorder colour.
border_type: EdgeTypeBorder type (none / raised / depressed / uniform / shadow).
pen_size: PenSizePen size.
pen_offset: PenOffsetPen offset (subscript/normal/superscript).
font_style: FontStyleFont style.
italics: boolPen italics.
underline: boolPen underline.
edge_type: EdgeTypePen edge type.
edge_color: ColorPen edge colour (SPC parm3, §8.10.5.10) — distinct from the window’s
border_color (SWA parm2, §8.10.5.8): the edge is drawn around each
glyph per edge_type, the border is drawn around the whole window.
fg_color: ColorPen foreground colour.
fg_opacity: OpacityPen foreground opacity.
bg_color: ColorPen background colour.
bg_opacity: OpacityPen background opacity.
Implementations§
Source§impl Window
impl Window
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
The window’s visible text, non-empty rows joined with \n, per-row
trailing spaces removed. Blank rows (interior or trailing) are dropped
entirely rather than emitted as an empty line: a run of them would
otherwise produce consecutive \ns, which downstream consumers (e.g.
timed-metadata’s WebVTT cue writer) read as a cue-block terminator.
Examples found in repository?
7fn main() {
8 let mut dec = Cea708Decoder::new();
9
10 // Build a Caption Channel Packet carrying one Service Block for service 1
11 // that: DefineWindow DF0 (visible, 2 rows × 16 cols), writes "HI THERE".
12 let block: &[u8] = &[
13 0x98, // DefineWindow DF0
14 0x20, // parm1: visible=YES, priority 0
15 0x00, // parm2: rp=0, anchor vertical 0
16 0x00, // parm3: anchor horizontal 0
17 0x01, // parm4: anchor point 0, row count = 1+1 = 2
18 0x0F, // parm5: column count = 15+1 = 16
19 0x00, // parm6: window/pen style 0 (auto)
20 b'H', b'I', b' ', b'T', b'H', b'E', b'R', b'E',
21 ];
22
23 // Service Block header: service_number = 1, block_size = block.len().
24 let mut sb: Vec<u8> = Vec::new();
25 sb.push((1 << 5) | (block.len() as u8));
26 sb.extend_from_slice(block);
27
28 // CCP header: sequence_number 0, packet_size_code covers the data.
29 let size_code = (sb.len().div_ceil(2) + 1) as u8;
30 let mut ccp: Vec<u8> = Vec::new();
31 ccp.push(size_code & 0x3F);
32 ccp.extend_from_slice(&sb);
33
34 dec.push_packet(&ccp);
35
36 println!("Service 1 text : {:?}", dec.service_text(1));
37 if let Some(w) = dec.windows(1)[0].as_ref() {
38 println!("Window 0 state : {}", w.state);
39 println!("Window 0 rows : {}", w.row_count);
40 println!("Window 0 cols : {}", w.column_count);
41 println!("Window 0 text : {:?}", w.text());
42 }
43}