mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-10-31 22:58:51 +00:00
fix formatted values constructors
In restrospect, building formatted values using operations on the `ONE` constant doesn't seem idiomatic. This commit uses new panicking constructors instead. See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1122
This commit is contained in:
parent
bd14e476f1
commit
bc5b51687d
5 changed files with 25 additions and 24 deletions
|
@ -337,7 +337,7 @@ impl Decrypter {
|
||||||
let size = size - total_chunks * box_::MACBYTES as u64;
|
let size = size - total_chunks * box_::MACBYTES as u64;
|
||||||
|
|
||||||
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
|
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
|
||||||
q.set(size * gst::format::Bytes::ONE);
|
q.set(gst::format::Bytes::from_u64(size));
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ impl Encrypter {
|
||||||
let size = size + crate::HEADERS_SIZE as u64;
|
let size = size + crate::HEADERS_SIZE as u64;
|
||||||
|
|
||||||
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
|
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
|
||||||
q.set(size * gst::format::Bytes::ONE);
|
q.set(gst::format::Bytes::from_u64(size));
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ fn test_pull_range() {
|
||||||
let (seekable, start, stop) = q.result();
|
let (seekable, start, stop) = q.result();
|
||||||
assert!(seekable);
|
assert!(seekable);
|
||||||
assert_eq!(start, gst::format::Bytes::ZERO.into());
|
assert_eq!(start, gst::format::Bytes::ZERO.into());
|
||||||
assert_eq!(stop, (6043 * gst::format::Bytes::ONE).into());
|
assert_eq!(stop, gst::format::Bytes::from_u64(6043).into());
|
||||||
|
|
||||||
// do pulls
|
// do pulls
|
||||||
let expected_array_1 = [
|
let expected_array_1 = [
|
||||||
|
|
|
@ -376,7 +376,7 @@ fn test_basic_request() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ fn test_basic_request_inverted_defaults() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ fn test_extra_headers() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ fn test_cookies_property() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ fn test_iradio_mode() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ fn test_audio_l16() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ fn test_authorization() {
|
||||||
if cursor.position() == 0 {
|
if cursor.position() == 0 {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
h.src.query_duration::<gst::format::Bytes>(),
|
h.src.query_duration::<gst::format::Bytes>(),
|
||||||
Some(expected_output.len() as u64 * gst::format::Bytes::ONE)
|
Some(gst::format::Bytes::from_usize(expected_output.len()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,13 +930,13 @@ fn test_seek_after_ready() {
|
||||||
assert_eq!(current_state, gst::State::Ready);
|
assert_eq!(current_state, gst::State::Ready);
|
||||||
|
|
||||||
h.run(|src| {
|
h.run(|src| {
|
||||||
src.seek_simple(gst::SeekFlags::FLUSH, 123 * gst::format::Bytes::ONE)
|
src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
src.set_state(gst::State::Playing).unwrap();
|
src.set_state(gst::State::Playing).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
let segment = h.wait_for_segment(false);
|
let segment = h.wait_for_segment(false);
|
||||||
assert_eq!(segment.start(), Some(123 * gst::format::Bytes::ONE));
|
assert_eq!(segment.start(), Some(gst::format::Bytes::from_u64(123)));
|
||||||
|
|
||||||
let mut expected_output = vec![0; 8192 - 123];
|
let mut expected_output = vec![0; 8192 - 123];
|
||||||
for (i, d) in expected_output.iter_mut().enumerate() {
|
for (i, d) in expected_output.iter_mut().enumerate() {
|
||||||
|
@ -1009,12 +1009,12 @@ fn test_seek_after_buffer_received() {
|
||||||
|
|
||||||
//seek to a position after a buffer is Received
|
//seek to a position after a buffer is Received
|
||||||
h.run(|src| {
|
h.run(|src| {
|
||||||
src.seek_simple(gst::SeekFlags::FLUSH, 123 * gst::format::Bytes::ONE)
|
src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
let segment = h.wait_for_segment(true);
|
let segment = h.wait_for_segment(true);
|
||||||
assert_eq!(segment.start(), Some(123 * gst::format::Bytes::ONE));
|
assert_eq!(segment.start(), Some(gst::format::Bytes::from_u64(123)));
|
||||||
|
|
||||||
let mut expected_output = vec![0; 8192 - 123];
|
let mut expected_output = vec![0; 8192 - 123];
|
||||||
for (i, d) in expected_output.iter_mut().enumerate() {
|
for (i, d) in expected_output.iter_mut().enumerate() {
|
||||||
|
@ -1086,8 +1086,8 @@ fn test_seek_with_stop_position() {
|
||||||
assert_eq!(buffer.offset(), 0);
|
assert_eq!(buffer.offset(), 0);
|
||||||
|
|
||||||
//seek to a position after a buffer is Received
|
//seek to a position after a buffer is Received
|
||||||
let start = 123 * gst::format::Bytes::ONE;
|
let start = gst::format::Bytes::from_u64(123);
|
||||||
let stop = 131 * gst::format::Bytes::ONE;
|
let stop = gst::format::Bytes::from_u64(131);
|
||||||
h.run(move |src| {
|
h.run(move |src| {
|
||||||
src.seek(
|
src.seek(
|
||||||
1.0,
|
1.0,
|
||||||
|
|
|
@ -100,13 +100,14 @@ fn bytes_to_time(bytes: Bytes) -> gst::ClockTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn time_to_bytes(time: gst::ClockTime) -> Bytes {
|
fn time_to_bytes(time: gst::ClockTime) -> Bytes {
|
||||||
|
Bytes::from_u64(
|
||||||
time.nseconds()
|
time.nseconds()
|
||||||
.mul_div_round(
|
.mul_div_round(
|
||||||
CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
|
CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
|
||||||
*gst::ClockTime::SECOND,
|
*gst::ClockTime::SECOND,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap(),
|
||||||
* Bytes::ONE
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BaseParseImpl for CdgParse {
|
impl BaseParseImpl for CdgParse {
|
||||||
|
@ -190,7 +191,7 @@ impl BaseParseImpl for CdgParse {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let pts = bytes_to_time(frame.offset() * Bytes::ONE);
|
let pts = bytes_to_time(Bytes::from_u64(frame.offset()));
|
||||||
let buffer = frame.buffer_mut().unwrap();
|
let buffer = frame.buffer_mut().unwrap();
|
||||||
buffer.set_pts(pts);
|
buffer.set_pts(pts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue