forked from mirrors/gstreamer-rs
Sync time code
This commit is contained in:
parent
413a6baa8c
commit
a8c1615a09
3 changed files with 24 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -493,6 +493,7 @@ dependencies = [
|
|||
"gstreamer-gl",
|
||||
"gstreamer-gl-egl",
|
||||
"gstreamer-gl-x11",
|
||||
"gstreamer-net",
|
||||
"gstreamer-pbutils",
|
||||
"gstreamer-play",
|
||||
"gstreamer-player",
|
||||
|
|
|
@ -43,6 +43,7 @@ winit = { version = "0.29", optional = true, default-features = false, features
|
|||
atomic_refcell = "0.1"
|
||||
data-encoding = "2.0"
|
||||
once_cell = "1"
|
||||
gst-net = { workspace = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows = { version = "0.56", features=["Win32_Graphics_Direct3D11",
|
||||
|
|
|
@ -52,7 +52,14 @@ unsafe impl Send for LayoutWrapper {}
|
|||
fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||
gst::init()?;
|
||||
|
||||
// Create the NTP clock and wait for synchronization.
|
||||
let clock = gst_net::NtpClock::new(None, "pool.ntp.org", 123, gst::ClockTime::ZERO);
|
||||
println!("Syncing to NTP clock");
|
||||
clock.wait_for_sync(gst::ClockTime::from_seconds(5))?;
|
||||
println!("Synced to NTP clock");
|
||||
|
||||
let pipeline = gst::Pipeline::default();
|
||||
pipeline.set_clock(Some(&clock))?;
|
||||
|
||||
// The videotestsrc supports multiple test patterns. In this example, we will use the
|
||||
// pattern with a white ball moving around the video's center point.
|
||||
|
@ -68,17 +75,29 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
|||
let caps = gst_video::VideoCapsBuilder::new()
|
||||
.width(800)
|
||||
.height(800)
|
||||
.framerate((15, 1).into())
|
||||
.build();
|
||||
let capsfilter = gst::ElementFactory::make("capsfilter")
|
||||
.property("caps", &caps)
|
||||
.build()?;
|
||||
|
||||
let videoconvert = gst::ElementFactory::make("videoconvert").build()?;
|
||||
|
||||
let timestamper = gst::ElementFactory::make("timecodestamper").build()?;
|
||||
timestamper.set_property_from_str("set", "always");
|
||||
timestamper.set_property_from_str("source", "rtc");
|
||||
|
||||
let timeoverlay = gst::ElementFactory::make("timeoverlay").build()?;
|
||||
timeoverlay.set_property("font-desc", "Sans Bold 26");
|
||||
timeoverlay.set_property_from_str("time-mode", "time-code");
|
||||
timeoverlay.set_property_from_str("halignment", "center");
|
||||
timeoverlay.set_property_from_str("valignment", "bottom");
|
||||
timeoverlay.set_property("color", 4200427042u32);
|
||||
|
||||
let videoconvert2 = gst::ElementFactory::make("videoconvert").build()?;
|
||||
let sink = gst::ElementFactory::make("autovideosink").build()?;
|
||||
|
||||
pipeline.add_many([&src, &overlay, &capsfilter, &videoconvert, &sink])?;
|
||||
gst::Element::link_many([&src, &overlay, &capsfilter, &videoconvert, &sink])?;
|
||||
pipeline.add_many([&src, &overlay, &capsfilter, &videoconvert, ×tamper, &timeoverlay, &videoconvert2, &sink])?;
|
||||
gst::Element::link_many([&src, &overlay, &capsfilter, &videoconvert, ×tamper, &timeoverlay, &videoconvert2, &sink])?;
|
||||
|
||||
// The PangoFontMap represents the set of fonts available for a particular rendering system.
|
||||
let fontmap = pangocairo::FontMap::new();
|
||||
|
|
Loading…
Reference in a new issue