mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-22 17:08:18 +00:00
Handle receiving in the beginning without clock gracefully
We'll only have a clock once the source element is actually in Playing.
This commit is contained in:
parent
bbdfae8cdd
commit
3ac1a6b288
1 changed files with 20 additions and 7 deletions
|
@ -1051,8 +1051,11 @@ impl<T: ReceiverType> Receiver<T> {
|
||||||
timestamp: i64,
|
timestamp: i64,
|
||||||
timecode: i64,
|
timecode: i64,
|
||||||
duration: gst::ClockTime,
|
duration: gst::ClockTime,
|
||||||
) -> (gst::ClockTime, gst::ClockTime) {
|
) -> Option<(gst::ClockTime, gst::ClockTime)> {
|
||||||
let clock = element.get_clock().unwrap();
|
let clock = match element.get_clock() {
|
||||||
|
None => return None,
|
||||||
|
Some(clock) => clock,
|
||||||
|
};
|
||||||
|
|
||||||
// For now take the current running time as PTS. At a later time we
|
// For now take the current running time as PTS. At a later time we
|
||||||
// will want to work with the timestamp given by the NDI SDK if available
|
// will want to work with the timestamp given by the NDI SDK if available
|
||||||
|
@ -1112,7 +1115,7 @@ impl<T: ReceiverType> Receiver<T> {
|
||||||
duration,
|
duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
(pts, duration)
|
Some((pts, duration))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1197,7 +1200,12 @@ impl Receiver<VideoReceiver> {
|
||||||
video_frame,
|
video_frame,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (pts, duration) = self.calculate_video_timestamp(element, &video_frame);
|
let (pts, duration) = self
|
||||||
|
.calculate_video_timestamp(element, &video_frame)
|
||||||
|
.ok_or_else(|| {
|
||||||
|
gst_debug!(self.0.cat, obj: element, "Flushing, dropping buffer");
|
||||||
|
gst::FlowError::CustomError
|
||||||
|
})?;
|
||||||
|
|
||||||
// Simply read all video frames while flushing but don't copy them or anything to
|
// Simply read all video frames while flushing but don't copy them or anything to
|
||||||
// make sure that we're not accumulating anything here
|
// make sure that we're not accumulating anything here
|
||||||
|
@ -1219,7 +1227,7 @@ impl Receiver<VideoReceiver> {
|
||||||
&self,
|
&self,
|
||||||
element: &gst_base::BaseSrc,
|
element: &gst_base::BaseSrc,
|
||||||
video_frame: &VideoFrame,
|
video_frame: &VideoFrame,
|
||||||
) -> (gst::ClockTime, gst::ClockTime) {
|
) -> Option<(gst::ClockTime, gst::ClockTime)> {
|
||||||
let duration = gst::SECOND
|
let duration = gst::SECOND
|
||||||
.mul_div_floor(
|
.mul_div_floor(
|
||||||
video_frame.frame_rate().1 as u64,
|
video_frame.frame_rate().1 as u64,
|
||||||
|
@ -1602,7 +1610,12 @@ impl Receiver<AudioReceiver> {
|
||||||
audio_frame,
|
audio_frame,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (pts, duration) = self.calculate_audio_timestamp(element, &audio_frame);
|
let (pts, duration) = self
|
||||||
|
.calculate_audio_timestamp(element, &audio_frame)
|
||||||
|
.ok_or_else(|| {
|
||||||
|
gst_debug!(self.0.cat, obj: element, "Flushing, dropping buffer");
|
||||||
|
gst::FlowError::CustomError
|
||||||
|
})?;
|
||||||
|
|
||||||
// Simply read all video frames while flushing but don't copy them or anything to
|
// Simply read all video frames while flushing but don't copy them or anything to
|
||||||
// make sure that we're not accumulating anything here
|
// make sure that we're not accumulating anything here
|
||||||
|
@ -1624,7 +1637,7 @@ impl Receiver<AudioReceiver> {
|
||||||
&self,
|
&self,
|
||||||
element: &gst_base::BaseSrc,
|
element: &gst_base::BaseSrc,
|
||||||
audio_frame: &AudioFrame,
|
audio_frame: &AudioFrame,
|
||||||
) -> (gst::ClockTime, gst::ClockTime) {
|
) -> Option<(gst::ClockTime, gst::ClockTime)> {
|
||||||
let duration = gst::SECOND
|
let duration = gst::SECOND
|
||||||
.mul_div_floor(
|
.mul_div_floor(
|
||||||
audio_frame.no_samples() as u64,
|
audio_frame.no_samples() as u64,
|
||||||
|
|
Loading…
Reference in a new issue