2024-08-19 20:40:52 -07:00
|
|
|
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();
|
|
|
|
|
2024-08-24 15:06:37 -07:00
|
|
|
let source = ElementFactory::make("mfvideosrc").build().unwrap();
|
2024-08-19 20:40:52 -07:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2024-08-24 15:06:37 -07:00
|
|
|
gst::Element::link_many(&[&source, &video_convert, &vp8enc, &rtp, app_sink.upcast_ref()]).unwrap();
|
2024-08-19 20:40:52 -07:00
|
|
|
|
|
|
|
Pipeline {
|
|
|
|
pipeline,
|
|
|
|
sink: app_sink,
|
|
|
|
}
|
|
|
|
}
|