2020-12-07 21:37:48 +00:00
|
|
|
// Copyright (C) 2021 Mathieu Duponchelle <mathieu@centricular.com>
|
|
|
|
//
|
2022-01-15 18:40:12 +00:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
|
|
|
|
// If a copy of the MPL was not distributed with this file, You can obtain one at
|
|
|
|
// <https://mozilla.org/MPL/2.0/>.
|
2020-12-07 21:37:48 +00:00
|
|
|
//
|
2022-01-15 18:40:12 +00:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
2020-12-07 21:37:48 +00:00
|
|
|
|
2021-06-03 18:20:54 +00:00
|
|
|
use gst::glib;
|
2020-12-07 21:37:48 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
#[derive(
|
2021-11-22 09:04:26 +00:00
|
|
|
Serialize, Deserialize, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum,
|
2020-12-07 21:37:48 +00:00
|
|
|
)]
|
|
|
|
#[repr(u32)]
|
2021-11-22 09:04:26 +00:00
|
|
|
#[enum_type(name = "GstTtToCea608Mode")]
|
2020-12-07 21:37:48 +00:00
|
|
|
pub enum Cea608Mode {
|
|
|
|
PopOn,
|
2021-01-19 21:22:51 +00:00
|
|
|
PaintOn,
|
2020-12-07 21:37:48 +00:00
|
|
|
RollUp2,
|
|
|
|
RollUp3,
|
|
|
|
RollUp4,
|
|
|
|
}
|
|
|
|
|
2022-06-30 12:44:07 +00:00
|
|
|
#[derive(Clone, Copy, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
2020-12-07 21:37:48 +00:00
|
|
|
pub enum TextStyle {
|
|
|
|
White,
|
|
|
|
Green,
|
|
|
|
Blue,
|
|
|
|
Cyan,
|
|
|
|
Red,
|
|
|
|
Yellow,
|
|
|
|
Magenta,
|
|
|
|
ItalicWhite,
|
|
|
|
}
|
|
|
|
|
2021-02-24 23:24:06 +00:00
|
|
|
impl From<u32> for TextStyle {
|
|
|
|
fn from(val: u32) -> Self {
|
|
|
|
match val {
|
|
|
|
0 => TextStyle::White,
|
|
|
|
1 => TextStyle::Green,
|
|
|
|
2 => TextStyle::Blue,
|
|
|
|
3 => TextStyle::Cyan,
|
|
|
|
4 => TextStyle::Red,
|
|
|
|
5 => TextStyle::Yellow,
|
|
|
|
6 => TextStyle::Magenta,
|
|
|
|
7 => TextStyle::ItalicWhite,
|
|
|
|
_ => TextStyle::White,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO allow indenting chunks
|
2021-07-16 15:54:45 +00:00
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
2020-12-07 21:37:48 +00:00
|
|
|
pub struct Chunk {
|
|
|
|
pub style: TextStyle,
|
|
|
|
pub underline: bool,
|
|
|
|
pub text: String,
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:54:45 +00:00
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
2020-12-07 21:37:48 +00:00
|
|
|
pub struct Line {
|
|
|
|
pub column: Option<u32>,
|
|
|
|
pub row: Option<u32>,
|
|
|
|
pub chunks: Vec<Chunk>,
|
|
|
|
/* In roll-up modes, new lines don't introduce a carriage return by
|
|
|
|
* default, but that can be overridden */
|
|
|
|
pub carriage_return: Option<bool>,
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:54:45 +00:00
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
2020-12-07 21:37:48 +00:00
|
|
|
pub struct Lines {
|
|
|
|
pub lines: Vec<Line>,
|
|
|
|
pub mode: Option<Cea608Mode>,
|
|
|
|
pub clear: Option<bool>,
|
|
|
|
}
|
2021-02-24 23:24:06 +00:00
|
|
|
|
|
|
|
impl Cea608Mode {
|
|
|
|
pub fn is_rollup(&self) -> bool {
|
|
|
|
*self == Cea608Mode::RollUp2 || *self == Cea608Mode::RollUp3 || *self == Cea608Mode::RollUp4
|
|
|
|
}
|
|
|
|
}
|