diff options
author | François Laignel <fengalin@free.fr> | 2022-10-10 14:55:32 +0300 |
---|---|---|
committer | François Laignel <fengalin@free.fr> | 2022-10-10 20:28:13 +0300 |
commit | bd14e476f16622d59a3a30d762b7f893c7c74614 (patch) | |
tree | 30da1afdc1308859231377629b62e9a8df0e7798 /video | |
parent | b1b707008f1995ea1118ab126586704c2e102233 (diff) |
Fix direct access to the inner specific formatted values
This is no longer available as this could lead to building a defined
value in Rust which could be interpreted as undefined in C due to
the sentinel `u64::MAX` for `None`.
Use the constants (e.g. `ONE`, `K`, `M`, ...) and operations to build
a value and deref (`*`) to get the quantity as an integer.
Diffstat (limited to 'video')
-rw-r--r-- | video/cdg/src/cdgparse/imp.rs | 19 | ||||
-rw-r--r-- | video/closedcaption/src/mcc_parse/imp.rs | 6 | ||||
-rw-r--r-- | video/closedcaption/src/scc_parse/imp.rs | 6 |
3 files changed, 15 insertions, 16 deletions
diff --git a/video/cdg/src/cdgparse/imp.rs b/video/cdg/src/cdgparse/imp.rs index 8ebf1e00..6bcd4158 100644 --- a/video/cdg/src/cdgparse/imp.rs +++ b/video/cdg/src/cdgparse/imp.rs @@ -92,7 +92,7 @@ impl ElementImpl for CdgParse { } fn bytes_to_time(bytes: Bytes) -> gst::ClockTime { - let nb = bytes.0 / CDG_PACKET_SIZE as u64; + let nb = *bytes / CDG_PACKET_SIZE as u64; gst::ClockTime::from_nseconds( nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD) .unwrap(), @@ -100,14 +100,13 @@ fn bytes_to_time(bytes: Bytes) -> gst::ClockTime { } fn time_to_bytes(time: gst::ClockTime) -> Bytes { - Bytes( - time.nseconds() - .mul_div_round( - CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64, - *gst::ClockTime::SECOND, - ) - .unwrap(), - ) + time.nseconds() + .mul_div_round( + CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64, + *gst::ClockTime::SECOND, + ) + .unwrap() + * Bytes::ONE } impl BaseParseImpl for CdgParse { @@ -191,7 +190,7 @@ impl BaseParseImpl for CdgParse { } }; - let pts = bytes_to_time(Bytes(frame.offset())); + let pts = bytes_to_time(frame.offset() * Bytes::ONE); let buffer = frame.buffer_mut().unwrap(); buffer.set_pts(pts); diff --git a/video/closedcaption/src/mcc_parse/imp.rs b/video/closedcaption/src/mcc_parse/imp.rs index 911ef21b..0c2e40bb 100644 --- a/video/closedcaption/src/mcc_parse/imp.rs +++ b/video/closedcaption/src/mcc_parse/imp.rs @@ -634,9 +634,9 @@ impl MccParse { )); } - let size = match q.result().try_into().unwrap() { - Some(gst::format::Bytes(size)) => size, - None => { + let size = match q.result() { + gst::GenericFormattedValue::Bytes(Some(size)) => *size, + _ => { return Err(gst::loggable_error!( CAT, "Failed to query upstream duration" diff --git a/video/closedcaption/src/scc_parse/imp.rs b/video/closedcaption/src/scc_parse/imp.rs index 5581f31a..f6c4f220 100644 --- a/video/closedcaption/src/scc_parse/imp.rs +++ b/video/closedcaption/src/scc_parse/imp.rs @@ -526,9 +526,9 @@ impl SccParse { )); } - let size = match q.result().try_into().unwrap() { - Some(gst::format::Bytes(size)) => size, - None => { + let size = match q.result() { + gst::GenericFormattedValue::Bytes(Some(size)) => *size, + _ => { return Err(gst::loggable_error!( CAT, "Failed to query upstream duration" |