Set priority and change pad request after fixes
This commit is contained in:
parent
de707f1c07
commit
64a5417c67
171
src/main.rs
171
src/main.rs
|
@ -236,7 +236,7 @@ fn receive_pipeline(pipeline: &gst::Pipeline) {
|
||||||
|
|
||||||
pipeline.debug_to_dot_file_with_ts(
|
pipeline.debug_to_dot_file_with_ts(
|
||||||
gst::DebugGraphDetails::all(),
|
gst::DebugGraphDetails::all(),
|
||||||
format!("Removed bin downstream to {pad_name}"),
|
format!("removed-bin-downstream-to-{pad_name}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,84 @@ fn send_pipeline(pipeline: &gst::Pipeline) {
|
||||||
pipeline.add_many([&mux, &sink]).unwrap();
|
pipeline.add_many([&mux, &sink]).unwrap();
|
||||||
|
|
||||||
mux.link(&sink).unwrap();
|
mux.link(&sink).unwrap();
|
||||||
|
|
||||||
|
let video1_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
||||||
|
let video2_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
||||||
|
let video3_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
||||||
|
let video4_mux_pad = mux.request_pad_simple("datagram").unwrap();
|
||||||
|
|
||||||
|
video1_mux_pad.set_property("priority", 1);
|
||||||
|
video2_mux_pad.set_property("priority", 2);
|
||||||
|
video3_mux_pad.set_property("priority", 3);
|
||||||
|
|
||||||
|
let video1_pad = video1.static_pad("src").unwrap();
|
||||||
|
let video2_pad = video2.static_pad("src").unwrap();
|
||||||
|
let video3_pad = video3.static_pad("src").unwrap();
|
||||||
|
let video4_pad = video4.static_pad("src").unwrap();
|
||||||
|
|
||||||
|
video1_pad.link(&video1_mux_pad).unwrap();
|
||||||
|
video2_pad.link(&video2_mux_pad).unwrap();
|
||||||
|
video3_pad.link(&video3_mux_pad).unwrap();
|
||||||
|
video4_pad.link(&video4_mux_pad).unwrap();
|
||||||
|
|
||||||
|
// Test releasing stream/request pad from muxer
|
||||||
|
let weak_pipeline = pipeline.downgrade();
|
||||||
|
glib::timeout_add_seconds_once(15, move || {
|
||||||
|
let pipeline = match weak_pipeline.upgrade() {
|
||||||
|
Some(pipeline) => pipeline,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
gst::info!(CAT, "Adding probe to remove Stream 3....");
|
||||||
|
video3_pad.add_probe(gst::PadProbeType::IDLE, move |pad, _probe_info| {
|
||||||
|
if let Some(peer) = pad.peer() {
|
||||||
|
gst::info!(CAT, "Removing Stream 3....");
|
||||||
|
|
||||||
|
pad.unlink(&peer).unwrap();
|
||||||
|
|
||||||
|
if let Some(parent) = peer
|
||||||
|
.parent()
|
||||||
|
.and_then(|p| p.downcast::<gst::Element>().ok())
|
||||||
|
{
|
||||||
|
gst::log!(
|
||||||
|
CAT,
|
||||||
|
"Releasing request pad {} from parent {}",
|
||||||
|
peer.name(),
|
||||||
|
parent.name()
|
||||||
|
);
|
||||||
|
parent.release_request_pad(&peer);
|
||||||
|
gst::log!(
|
||||||
|
CAT,
|
||||||
|
"Released request pad {} from parent {}",
|
||||||
|
peer.name(),
|
||||||
|
parent.name()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(parent) = pad.parent().and_then(|p| p.downcast::<gst::Element>().ok()) {
|
||||||
|
pipeline.remove(&parent).unwrap();
|
||||||
|
|
||||||
|
let weak_pipeline = pipeline.downgrade();
|
||||||
|
glib::idle_add_once(move || {
|
||||||
|
let _ = match weak_pipeline.upgrade() {
|
||||||
|
Some(self_) => self_,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = parent.set_state(gst::State::Null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst::info!(CAT, "Removed Stream 3");
|
||||||
|
|
||||||
|
pipeline.debug_to_dot_file_with_ts(gst::DebugGraphDetails::all(), "removed-stream-3");
|
||||||
|
|
||||||
|
gst::PadProbeReturn::Drop
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
pipeline.debug_to_dot_file_with_ts(gst::DebugGraphDetails::all(), "setup-quic-mux");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -331,97 +409,6 @@ fn main() {
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if !cli.receiver {
|
|
||||||
let mux = pipeline.by_name("quic-mux").unwrap();
|
|
||||||
|
|
||||||
let video1 = pipeline.by_name("Stream 1").unwrap();
|
|
||||||
let video2 = pipeline.by_name("Stream 2").unwrap();
|
|
||||||
let video3 = pipeline.by_name("Stream 3").unwrap();
|
|
||||||
let video4 = pipeline.by_name("Datagram").unwrap();
|
|
||||||
|
|
||||||
let video1_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
|
||||||
let video2_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
|
||||||
let video3_mux_pad = mux.request_pad_simple("stream_uni_%u").unwrap();
|
|
||||||
let video4_mux_pad = mux.request_pad_simple("datagram").unwrap();
|
|
||||||
|
|
||||||
let video1_pad = video1.static_pad("src").unwrap();
|
|
||||||
let video2_pad = video2.static_pad("src").unwrap();
|
|
||||||
let video3_pad = video3.static_pad("src").unwrap();
|
|
||||||
let video4_pad = video4.static_pad("src").unwrap();
|
|
||||||
|
|
||||||
video1_pad.link(&video1_mux_pad).unwrap();
|
|
||||||
video2_pad.link(&video2_mux_pad).unwrap();
|
|
||||||
video3_pad.link(&video3_mux_pad).unwrap();
|
|
||||||
video4_pad.link(&video4_mux_pad).unwrap();
|
|
||||||
|
|
||||||
mux.sync_state_with_parent().unwrap();
|
|
||||||
video1.sync_state_with_parent().unwrap();
|
|
||||||
video2.sync_state_with_parent().unwrap();
|
|
||||||
video3.sync_state_with_parent().unwrap();
|
|
||||||
|
|
||||||
pipeline.debug_to_dot_file_with_ts(gst::DebugGraphDetails::all(), "setup-quic-mux");
|
|
||||||
|
|
||||||
// Test releasing stream/request pad from muxer
|
|
||||||
let weak_pipeline = pipeline.downgrade();
|
|
||||||
glib::timeout_add_seconds_once(15, move || {
|
|
||||||
let pipeline = match weak_pipeline.upgrade() {
|
|
||||||
Some(pipeline) => pipeline,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
gst::info!(CAT, "Adding probe to remove Stream 3....");
|
|
||||||
video3_pad.add_probe(gst::PadProbeType::IDLE, move |pad, _probe_info| {
|
|
||||||
if let Some(peer) = pad.peer() {
|
|
||||||
gst::info!(CAT, "Removing Stream 3....");
|
|
||||||
|
|
||||||
pad.unlink(&peer).unwrap();
|
|
||||||
|
|
||||||
if let Some(parent) = peer
|
|
||||||
.parent()
|
|
||||||
.and_then(|p| p.downcast::<gst::Element>().ok())
|
|
||||||
{
|
|
||||||
gst::log!(
|
|
||||||
CAT,
|
|
||||||
"Releasing request pad {} from parent {}",
|
|
||||||
peer.name(),
|
|
||||||
parent.name()
|
|
||||||
);
|
|
||||||
parent.release_request_pad(&peer);
|
|
||||||
gst::log!(
|
|
||||||
CAT,
|
|
||||||
"Released request pad {} from parent {}",
|
|
||||||
peer.name(),
|
|
||||||
parent.name()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(parent) =
|
|
||||||
pad.parent().and_then(|p| p.downcast::<gst::Element>().ok())
|
|
||||||
{
|
|
||||||
pipeline.remove(&parent).unwrap();
|
|
||||||
|
|
||||||
let weak_pipeline = pipeline.downgrade();
|
|
||||||
glib::idle_add_once(move || {
|
|
||||||
let _ = match weak_pipeline.upgrade() {
|
|
||||||
Some(self_) => self_,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = parent.set_state(gst::State::Null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gst::info!(CAT, "Removed Stream 3");
|
|
||||||
|
|
||||||
pipeline
|
|
||||||
.debug_to_dot_file_with_ts(gst::DebugGraphDetails::all(), "removed-Stream-3");
|
|
||||||
|
|
||||||
gst::PadProbeReturn::Drop
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let weak_pipeline = pipeline.downgrade();
|
let weak_pipeline = pipeline.downgrade();
|
||||||
// Capture pipeline graph 5 secs later to correctly capture STATE changes.
|
// Capture pipeline graph 5 secs later to correctly capture STATE changes.
|
||||||
glib::timeout_add_seconds_once(10, move || {
|
glib::timeout_add_seconds_once(10, move || {
|
||||||
|
|
Loading…
Reference in a new issue