mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 13:31:00 +00:00
rtspsrc2: Emit EOS if any ssrc gets a BYE packet or times out
This allows us to exit when the live-stream ends. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1425>
This commit is contained in:
parent
975556c06b
commit
44e49a06a0
1 changed files with 22 additions and 2 deletions
|
@ -1088,9 +1088,29 @@ struct RtspManager {
|
||||||
impl RtspManager {
|
impl RtspManager {
|
||||||
fn new(rtpbin2: bool) -> Self {
|
fn new(rtpbin2: bool) -> Self {
|
||||||
let name = if rtpbin2 { "rtpbin2" } else { "rtpbin" };
|
let name = if rtpbin2 { "rtpbin2" } else { "rtpbin" };
|
||||||
|
let manager = gst::ElementFactory::make_with_name(name, None)
|
||||||
|
.unwrap_or_else(|_| panic!("{name} not found"));
|
||||||
|
if !rtpbin2 {
|
||||||
|
let on_bye = |args: &[glib::Value]| {
|
||||||
|
let m = args[0].get::<gst::Element>().unwrap();
|
||||||
|
let Some(obj) = m.parent() else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
let bin = obj.downcast::<gst::Bin>().unwrap();
|
||||||
|
bin.send_event(gst::event::Eos::new());
|
||||||
|
None
|
||||||
|
};
|
||||||
|
manager.connect("on-bye-ssrc", true, move |args| {
|
||||||
|
gst::info!(CAT, "Received BYE packet");
|
||||||
|
on_bye(args)
|
||||||
|
});
|
||||||
|
manager.connect("on-bye-timeout", true, move |args| {
|
||||||
|
gst::info!(CAT, "BYE due to timeout");
|
||||||
|
on_bye(args)
|
||||||
|
});
|
||||||
|
}
|
||||||
RtspManager {
|
RtspManager {
|
||||||
inner: gst::ElementFactory::make_with_name(name, None)
|
inner: manager,
|
||||||
.unwrap_or_else(|_| panic!("{name} not found")),
|
|
||||||
using_rtpbin2: rtpbin2,
|
using_rtpbin2: rtpbin2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue