use gstreamer::{ self as gst, prelude::{Cast, GstBinExtManual}, ElementFactory, }; use gstreamer_app as gst_app; pub struct Pipeline { pub pipeline: gst::Pipeline, pub sink: gst_app::AppSink, } pub fn new_pipeline() -> Pipeline { let pipeline = gst::Pipeline::builder() .name("camera_to_rtp_pipeine") .build(); let source = ElementFactory::make("v4l2src").build().unwrap(); let video_convert = ElementFactory::make("videoconvert").build().unwrap(); let vp8enc = ElementFactory::make("vp8enc").build().unwrap(); let rtp = ElementFactory::make("rtpvp8pay").build().unwrap(); let app_sink = gst_app::AppSink::builder().build(); pipeline .add_many([ &source, &video_convert, &vp8enc, &rtp, app_sink.upcast_ref(), ]) .expect("Could not add all the stuff to the pipeline"); gst::Element::link_many(&[&source, &video_convert, &vp8enc, &rtp]).unwrap(); Pipeline { pipeline, sink: app_sink, } }