Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Laignel <fengalin@free.fr>2022-10-10 14:55:32 +0300
committerFrançois Laignel <fengalin@free.fr>2022-10-10 20:28:13 +0300
commitbd14e476f16622d59a3a30d762b7f893c7c74614 (patch)
tree30da1afdc1308859231377629b62e9a8df0e7798 /generic
parentb1b707008f1995ea1118ab126586704c2e102233 (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 'generic')
-rw-r--r--generic/sodium/src/decrypter/imp.rs9
-rw-r--r--generic/sodium/src/encrypter/imp.rs9
-rw-r--r--generic/sodium/tests/decrypter.rs4
3 files changed, 10 insertions, 12 deletions
diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs
index 546b25033..b968c01d0 100644
--- a/generic/sodium/src/decrypter/imp.rs
+++ b/generic/sodium/src/decrypter/imp.rs
@@ -311,11 +311,10 @@ impl Decrypter {
return false;
}
- let size = match peer_query.result().try_into().unwrap() {
- Some(gst::format::Bytes(size)) => size,
- None => {
+ let size = match peer_query.result() {
+ gst::GenericFormattedValue::Bytes(Some(size)) => *size,
+ _ => {
gst::error!(CAT, "Failed to query upstream duration");
-
return false;
}
};
@@ -338,7 +337,7 @@ impl Decrypter {
let size = size - total_chunks * box_::MACBYTES as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
- q.set(gst::format::Bytes(size));
+ q.set(size * gst::format::Bytes::ONE);
true
}
diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs
index b0cc8a4c2..af7961e81 100644
--- a/generic/sodium/src/encrypter/imp.rs
+++ b/generic/sodium/src/encrypter/imp.rs
@@ -289,11 +289,10 @@ impl Encrypter {
return false;
}
- let size = match peer_query.result().try_into().unwrap() {
- Some(gst::format::Bytes(size)) => size,
- None => {
+ let size = match peer_query.result() {
+ gst::GenericFormattedValue::Bytes(Some(size)) => *size,
+ _ => {
gst::error!(CAT, "Failed to query upstream duration");
-
return false;
}
};
@@ -315,7 +314,7 @@ impl Encrypter {
let size = size + crate::HEADERS_SIZE as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
- q.set(gst::format::Bytes(size));
+ q.set(size * gst::format::Bytes::ONE);
true
}
diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs
index ed99ced83..6b4a4881d 100644
--- a/generic/sodium/tests/decrypter.rs
+++ b/generic/sodium/tests/decrypter.rs
@@ -190,8 +190,8 @@ fn test_pull_range() {
// get the seeking capabilities
let (seekable, start, stop) = q.result();
assert!(seekable);
- assert_eq!(start, gst::format::Bytes(0).into());
- assert_eq!(stop, gst::format::Bytes(6043).into());
+ assert_eq!(start, gst::format::Bytes::ZERO.into());
+ assert_eq!(stop, (6043 * gst::format::Bytes::ONE).into());
// do pulls
let expected_array_1 = [