mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-23 02:26:35 +00:00
closedcaption/mccparse: Refactor parser state handling a bit
To make it a bit less confusing. The name of the state previously was what was previously parsed, not what is expected now.
This commit is contained in:
parent
163e8cf1a0
commit
3c226a05d5
1 changed files with 10 additions and 8 deletions
|
@ -46,8 +46,8 @@ pub enum MccLine<'a> {
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
enum State {
|
enum State {
|
||||||
Init,
|
|
||||||
Header,
|
Header,
|
||||||
|
EmptyAfterHeader,
|
||||||
Comments,
|
Comments,
|
||||||
Metadata,
|
Metadata,
|
||||||
Captions,
|
Captions,
|
||||||
|
@ -349,7 +349,9 @@ where
|
||||||
/// MCC parser the parses line-by-line and keeps track of the current state in the file.
|
/// MCC parser the parses line-by-line and keeps track of the current state in the file.
|
||||||
impl MccParser {
|
impl MccParser {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { state: State::Init }
|
Self {
|
||||||
|
state: State::Header,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_scan_captions() -> Self {
|
pub fn new_scan_captions() -> Self {
|
||||||
|
@ -359,7 +361,7 @@ impl MccParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
self.state = State::Init;
|
self.state = State::Header;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_line<'a>(
|
pub fn parse_line<'a>(
|
||||||
|
@ -369,15 +371,15 @@ impl MccParser {
|
||||||
) -> Result<MccLine<'a>, combine::easy::Errors<u8, &'a [u8], combine::stream::PointerOffset>>
|
) -> Result<MccLine<'a>, combine::easy::Errors<u8, &'a [u8], combine::stream::PointerOffset>>
|
||||||
{
|
{
|
||||||
match self.state {
|
match self.state {
|
||||||
State::Init => header()
|
State::Header => header()
|
||||||
.message("while in Init state")
|
.message("while in Header state")
|
||||||
.easy_parse(line)
|
.easy_parse(line)
|
||||||
.map(|v| {
|
.map(|v| {
|
||||||
self.state = State::Header;
|
self.state = State::EmptyAfterHeader;
|
||||||
v.0
|
v.0
|
||||||
}),
|
}),
|
||||||
State::Header => empty_line()
|
State::EmptyAfterHeader => empty_line()
|
||||||
.message("while in Header state")
|
.message("while in EmptyAfterHeader state")
|
||||||
.easy_parse(line)
|
.easy_parse(line)
|
||||||
.map(|v| {
|
.map(|v| {
|
||||||
self.state = State::Comments;
|
self.state = State::Comments;
|
||||||
|
|
Loading…
Reference in a new issue