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
path: root/video/cdg
diff options
context:
space:
mode:
authorFrançois Laignel <fengalin@free.fr>2021-06-04 20:06:24 +0300
committerFrançois Laignel <fengalin@free.fr>2021-06-05 11:36:21 +0300
commite16cad7c8f4000ab5b1d649e54b8d6f8e19cf154 (patch)
tree4dfa96ee5452d77320399452e3d87d9f56217a7a /video/cdg
parentc2de0649a736fde8435434e0e6483c5ad96fdfe2 (diff)
video: migrate to new ClockTime design
Diffstat (limited to 'video/cdg')
-rw-r--r--video/cdg/src/cdgdec/imp.rs7
-rw-r--r--video/cdg/src/cdgparse/imp.rs38
-rw-r--r--video/cdg/tests/cdgdec.rs2
3 files changed, 25 insertions, 22 deletions
diff --git a/video/cdg/src/cdgdec/imp.rs b/video/cdg/src/cdgdec/imp.rs
index 678af14be..189446d2c 100644
--- a/video/cdg/src/cdgdec/imp.rs
+++ b/video/cdg/src/cdgdec/imp.rs
@@ -186,7 +186,12 @@ impl VideoDecoderImpl for CdgDec {
}
}
- gst_debug!(CAT, obj: element, "Finish frame pts={}", frame.pts());
+ gst_debug!(
+ CAT,
+ obj: element,
+ "Finish frame pts={}",
+ frame.pts().display()
+ );
element.finish_frame(frame)
}
diff --git a/video/cdg/src/cdgparse/imp.rs b/video/cdg/src/cdgparse/imp.rs
index c89ab323f..85123c5ee 100644
--- a/video/cdg/src/cdgparse/imp.rs
+++ b/video/cdg/src/cdgparse/imp.rs
@@ -10,7 +10,6 @@ use gst::format::Bytes;
use gst::glib;
use gst::gst_debug;
use gst::subclass::prelude::*;
-use gst::SECOND_VAL;
use gst_base::prelude::*;
use gst_base::subclass::prelude::*;
use once_cell::sync::Lazy;
@@ -94,23 +93,22 @@ impl ElementImpl for CdgParse {
}
fn bytes_to_time(bytes: Bytes) -> gst::ClockTime {
- match bytes {
- Bytes(Some(bytes)) => {
- let nb = bytes / CDG_PACKET_SIZE as u64;
- gst::ClockTime(nb.mul_div_round(SECOND_VAL, CDG_PACKET_PERIOD))
- }
- Bytes(None) => gst::ClockTime::none(),
- }
+ let nb = bytes.0 / CDG_PACKET_SIZE as u64;
+ gst::ClockTime::from_nseconds(
+ nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD)
+ .unwrap(),
+ )
}
fn time_to_bytes(time: gst::ClockTime) -> Bytes {
- match time.nseconds() {
- Some(time) => {
- let bytes = time.mul_div_round(CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64, SECOND_VAL);
- Bytes(bytes)
- }
- None => Bytes(None),
- }
+ Bytes(
+ time.nseconds()
+ .mul_div_round(
+ CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
+ *gst::ClockTime::SECOND,
+ )
+ .unwrap(),
+ )
}
impl BaseParseImpl for CdgParse {
@@ -122,8 +120,8 @@ impl BaseParseImpl for CdgParse {
let pad = element.src_pad();
if pad.query(&mut query) {
let size = query.result();
- let duration = bytes_to_time(size.try_into().unwrap());
- element.set_duration(duration, 0);
+ let bytes: Option<Bytes> = size.try_into().unwrap();
+ element.set_duration(bytes.map(bytes_to_time), 0);
}
Ok(())
@@ -198,7 +196,7 @@ impl BaseParseImpl for CdgParse {
}
};
- let pts = bytes_to_time(Bytes(Some(frame.offset())));
+ let pts = bytes_to_time(Bytes(frame.offset()));
let buffer = frame.buffer_mut().unwrap();
buffer.set_pts(pts);
@@ -226,10 +224,10 @@ impl BaseParseImpl for CdgParse {
match (src_val, dest_format) {
(gst::GenericFormattedValue::Bytes(bytes), gst::Format::Time) => {
- Some(bytes_to_time(bytes).into())
+ Some(bytes.map(bytes_to_time).into())
}
(gst::GenericFormattedValue::Time(time), gst::Format::Bytes) => {
- Some(time_to_bytes(time).into())
+ Some(time.map(time_to_bytes).into())
}
_ => None,
}
diff --git a/video/cdg/tests/cdgdec.rs b/video/cdg/tests/cdgdec.rs
index 0c9ee6fda..e55b02316 100644
--- a/video/cdg/tests/cdgdec.rs
+++ b/video/cdg/tests/cdgdec.rs
@@ -84,7 +84,7 @@ fn test_cdgdec() {
.expect("Unable to set the pipeline to the `Playing` state");
let bus = pipeline.bus().unwrap();
- for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
+ for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView;
match msg.view() {
MessageView::Error(err) => {