mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-02-21 07:06:19 +00:00
closedcaption: Update to winnow 0.7
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2082>
This commit is contained in:
parent
9d6272b8e0
commit
bb5e0c9917
5 changed files with 25 additions and 34 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -2581,7 +2581,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"smallvec",
|
||||
"uuid",
|
||||
"winnow 0.6.26",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -7834,7 +7834,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow 0.7.2",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -8706,15 +8706,6 @@ version = "0.52.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e90edd2ac1aa278a5c4599b1d89cf03074b610800f866d4026dc199d7929a28"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.2"
|
||||
|
|
|
@ -25,7 +25,7 @@ cea608-types = "0.1.1"
|
|||
gst = { workspace = true, features = ["v1_20"]}
|
||||
gst-base = { workspace = true, features = ["v1_22"]}
|
||||
gst-video = { workspace = true, features = ["v1_16"]}
|
||||
winnow = "0.6"
|
||||
winnow = "0.7"
|
||||
smallvec = "1"
|
||||
bitstream-io = "2.3"
|
||||
itertools = "0.13"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use either::Either;
|
||||
|
||||
use crate::parser_utils::{digits, digits_range, end_of_line, timecode, TimeCode};
|
||||
use winnow::{error::StrContext, PResult, Parser};
|
||||
use winnow::{error::StrContext, ModalParser, ModalResult, Parser};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum MccLine<'a> {
|
||||
|
@ -37,7 +37,7 @@ pub struct MccParser {
|
|||
}
|
||||
|
||||
/// Parser for the MCC header
|
||||
fn header<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn header<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
use winnow::combinator::{alt, opt};
|
||||
use winnow::token::literal;
|
||||
|
||||
|
@ -54,7 +54,7 @@ fn header<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
|
||||
/// Parser for an MCC comment, i.e. a line starting with `//`. We don't return the actual comment
|
||||
/// text as it's irrelevant for us.
|
||||
fn comment<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn comment<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
use winnow::token::{literal, rest};
|
||||
|
||||
(literal("//"), rest)
|
||||
|
@ -64,7 +64,7 @@ fn comment<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
}
|
||||
|
||||
/// Parser for the MCC UUID line.
|
||||
fn uuid<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn uuid<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
use winnow::token::{literal, take_while};
|
||||
|
||||
(
|
||||
|
@ -78,7 +78,7 @@ fn uuid<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
}
|
||||
|
||||
/// Parser for the MCC Time Code Rate line.
|
||||
fn time_code_rate<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn time_code_rate<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
use winnow::combinator::opt;
|
||||
use winnow::token::literal;
|
||||
|
||||
|
@ -94,7 +94,7 @@ fn time_code_rate<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
}
|
||||
|
||||
/// Parser for generic MCC metadata lines in the form `key=value`.
|
||||
fn metadata<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn metadata<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
use winnow::token::{one_of, take_while};
|
||||
|
||||
(
|
||||
|
@ -109,7 +109,7 @@ fn metadata<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
}
|
||||
|
||||
/// Parser that accepts only an empty line
|
||||
fn empty_line<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
||||
fn empty_line<'a>(s: &mut &'a [u8]) -> ModalResult<MccLine<'a>> {
|
||||
end_of_line
|
||||
.map(|_| MccLine::Empty)
|
||||
.context(StrContext::Label("invalid empty line"))
|
||||
|
@ -121,7 +121,7 @@ fn empty_line<'a>(s: &mut &'a [u8]) -> PResult<MccLine<'a>> {
|
|||
///
|
||||
/// It returns an `Either` of the single hex encoded byte or the short-cut byte sequence as a
|
||||
/// static byte slice.
|
||||
fn mcc_payload_item(s: &mut &[u8]) -> PResult<Either<u8, &'static [u8]>> {
|
||||
fn mcc_payload_item(s: &mut &[u8]) -> ModalResult<Either<u8, &'static [u8]>> {
|
||||
use winnow::combinator::alt;
|
||||
use winnow::stream::AsChar;
|
||||
use winnow::token::{literal, take_while};
|
||||
|
@ -209,7 +209,7 @@ fn mcc_payload_item(s: &mut &[u8]) -> PResult<Either<u8, &'static [u8]>> {
|
|||
}
|
||||
|
||||
/// Parser for the whole MCC payload with conversion to the underlying byte values.
|
||||
fn mcc_payload(s: &mut &[u8]) -> PResult<Vec<u8>> {
|
||||
fn mcc_payload(s: &mut &[u8]) -> ModalResult<Vec<u8>> {
|
||||
use winnow::combinator::repeat;
|
||||
|
||||
repeat(1.., mcc_payload_item)
|
||||
|
@ -227,13 +227,13 @@ fn mcc_payload(s: &mut &[u8]) -> PResult<Vec<u8>> {
|
|||
/// Parser for a MCC caption line in the form `timecode\tpayload`.
|
||||
fn caption<'a>(
|
||||
parse_payload: bool,
|
||||
) -> impl Parser<&'a [u8], MccLine<'a>, winnow::error::ContextError> {
|
||||
) -> impl ModalParser<&'a [u8], MccLine<'a>, winnow::error::ContextError> {
|
||||
use winnow::combinator::opt;
|
||||
use winnow::token::{one_of, take_while};
|
||||
|
||||
fn parse<'a>(
|
||||
parse_payload: bool,
|
||||
) -> impl Parser<&'a [u8], Option<Vec<u8>>, winnow::error::ContextError> {
|
||||
) -> impl ModalParser<&'a [u8], Option<Vec<u8>>, winnow::error::ContextError> {
|
||||
move |s: &mut &'a [u8]| {
|
||||
if parse_payload {
|
||||
mcc_payload.map(Some).parse_next(s)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use winnow::{error::StrContext, PResult, Parser};
|
||||
use winnow::{error::StrContext, ModalParser, ModalResult, Parser};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct TimeCode {
|
||||
|
@ -18,7 +18,7 @@ pub struct TimeCode {
|
|||
}
|
||||
|
||||
/// Parser for parsing a run of ASCII, decimal digits and converting them into a `u32`
|
||||
pub fn digits(s: &mut &[u8]) -> PResult<u32> {
|
||||
pub fn digits(s: &mut &[u8]) -> ModalResult<u32> {
|
||||
use winnow::stream::AsChar;
|
||||
use winnow::token::take_while;
|
||||
|
||||
|
@ -32,7 +32,7 @@ pub fn digits(s: &mut &[u8]) -> PResult<u32> {
|
|||
/// in the allowed range.
|
||||
pub fn digits_range<'a, R: std::ops::RangeBounds<u32>>(
|
||||
range: R,
|
||||
) -> impl Parser<&'a [u8], u32, winnow::error::ContextError> {
|
||||
) -> impl ModalParser<&'a [u8], u32, winnow::error::ContextError> {
|
||||
move |s: &mut &'a [u8]| {
|
||||
digits
|
||||
.verify(|v| range.contains(v))
|
||||
|
@ -42,7 +42,7 @@ pub fn digits_range<'a, R: std::ops::RangeBounds<u32>>(
|
|||
}
|
||||
|
||||
/// Parser for a timecode in the form `hh:mm:ss:fs`
|
||||
pub fn timecode(s: &mut &[u8]) -> PResult<TimeCode> {
|
||||
pub fn timecode(s: &mut &[u8]) -> ModalResult<TimeCode> {
|
||||
use winnow::token::one_of;
|
||||
|
||||
(
|
||||
|
@ -66,7 +66,7 @@ pub fn timecode(s: &mut &[u8]) -> PResult<TimeCode> {
|
|||
}
|
||||
|
||||
/// Parser that checks for EOF and optionally `\n` or `\r\n` before EOF
|
||||
pub fn end_of_line(s: &mut &[u8]) -> PResult<()> {
|
||||
pub fn end_of_line(s: &mut &[u8]) -> ModalResult<()> {
|
||||
use winnow::combinator::alt;
|
||||
use winnow::combinator::{eof, opt};
|
||||
use winnow::token::literal;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::parser_utils::{end_of_line, timecode, TimeCode};
|
||||
use winnow::{error::StrContext, PResult, Parser};
|
||||
use winnow::{error::StrContext, ModalResult, Parser};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum SccLine {
|
||||
|
@ -30,7 +30,7 @@ pub struct SccParser {
|
|||
}
|
||||
|
||||
/// Parser for the SCC header
|
||||
fn header(s: &mut &[u8]) -> PResult<SccLine> {
|
||||
fn header(s: &mut &[u8]) -> ModalResult<SccLine> {
|
||||
use winnow::combinator::opt;
|
||||
use winnow::token::literal;
|
||||
|
||||
|
@ -45,7 +45,7 @@ fn header(s: &mut &[u8]) -> PResult<SccLine> {
|
|||
}
|
||||
|
||||
/// Parser that accepts only an empty line
|
||||
fn empty_line(s: &mut &[u8]) -> PResult<SccLine> {
|
||||
fn empty_line(s: &mut &[u8]) -> ModalResult<SccLine> {
|
||||
end_of_line
|
||||
.map(|_| SccLine::Empty)
|
||||
.context(StrContext::Label("invalid empty line"))
|
||||
|
@ -54,7 +54,7 @@ fn empty_line(s: &mut &[u8]) -> PResult<SccLine> {
|
|||
|
||||
/// A single SCC payload item. This is ASCII hex encoded bytes.
|
||||
/// It returns an tuple of `(u8, u8)` of the hex encoded bytes.
|
||||
fn scc_payload_item(s: &mut &[u8]) -> PResult<(u8, u8)> {
|
||||
fn scc_payload_item(s: &mut &[u8]) -> ModalResult<(u8, u8)> {
|
||||
use winnow::stream::AsChar;
|
||||
use winnow::token::take_while;
|
||||
|
||||
|
@ -77,7 +77,7 @@ fn scc_payload_item(s: &mut &[u8]) -> PResult<(u8, u8)> {
|
|||
}
|
||||
|
||||
/// Parser for the whole SCC payload with conversion to the underlying byte values.
|
||||
fn scc_payload(s: &mut &[u8]) -> PResult<Vec<u8>> {
|
||||
fn scc_payload(s: &mut &[u8]) -> ModalResult<Vec<u8>> {
|
||||
use winnow::combinator::{alt, repeat};
|
||||
use winnow::token::literal;
|
||||
|
||||
|
@ -98,7 +98,7 @@ fn scc_payload(s: &mut &[u8]) -> PResult<Vec<u8>> {
|
|||
}
|
||||
|
||||
/// Parser for a SCC caption line in the form `timecode\tpayload`.
|
||||
fn caption(s: &mut &[u8]) -> PResult<SccLine> {
|
||||
fn caption(s: &mut &[u8]) -> ModalResult<SccLine> {
|
||||
use winnow::ascii::multispace0;
|
||||
use winnow::token::literal;
|
||||
|
||||
|
|
Loading…
Reference in a new issue