feat(gst): add glib dependency and update video texture handling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
pub mod errors;
|
||||
pub mod playbin3;
|
||||
use errors::*;
|
||||
use gstreamer::prelude::*;
|
||||
use std::sync::Arc;
|
||||
@@ -31,8 +32,11 @@ impl Gst {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Sink {
|
||||
element: gstreamer::Element,
|
||||
pub struct Bin {
|
||||
bin: gstreamer::Bin,
|
||||
}
|
||||
pub struct Sample {
|
||||
sample: gstreamer::Sample,
|
||||
}
|
||||
|
||||
pub struct Pipeline {
|
||||
@@ -81,9 +85,13 @@ pub struct Bus {
|
||||
impl Bus {
|
||||
pub fn iter_timed(
|
||||
&self,
|
||||
timeout: impl Into<Option<gstreamer::ClockTime>>,
|
||||
timeout: impl Into<Option<core::time::Duration>>,
|
||||
) -> gstreamer::bus::Iter<'_> {
|
||||
self.bus.iter_timed(timeout)
|
||||
let clocktime = match timeout.into() {
|
||||
Some(dur) => gstreamer::ClockTime::try_from(dur).ok(),
|
||||
None => gstreamer::ClockTime::NONE,
|
||||
};
|
||||
self.bus.iter_timed(clocktime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +104,17 @@ pub struct Element {
|
||||
element: gstreamer::Element,
|
||||
}
|
||||
|
||||
pub struct AppSink {
|
||||
appsink: gstreamer_app::AppSink,
|
||||
}
|
||||
|
||||
pub struct Playbin3Builder {
|
||||
uri: Option<String>,
|
||||
video_sink: Option<Element>,
|
||||
audio_sink: Option<Element>,
|
||||
text_sink: Option<Element>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gst_parse_pipeline() {
|
||||
let gst = Gst::new();
|
||||
@@ -124,7 +143,7 @@ fn gst_play_pipeline() {
|
||||
.set_state(gstreamer::State::Playing)
|
||||
.expect("Unable to set the pipeline to the `Playing` state");
|
||||
|
||||
for msg in bus.iter_timed(gstreamer::ClockTime::NONE) {
|
||||
for msg in bus.iter_timed(None) {
|
||||
use gstreamer::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
@@ -225,7 +244,7 @@ fn test_appsink() {
|
||||
.set_state(gstreamer::State::Playing)
|
||||
.expect("Unable to set the pipeline to the `Playing` state");
|
||||
|
||||
for msg in bus.iter_timed(gstreamer::ClockTime::NONE) {
|
||||
for msg in bus.iter_timed(None) {
|
||||
use gstreamer::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
@@ -243,3 +262,38 @@ fn test_appsink() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gst_test_manual_pipeline() {
|
||||
use gstreamer as gst;
|
||||
use gstreamer::prelude::*;
|
||||
// Initialize GStreamer
|
||||
gst::init().unwrap();
|
||||
|
||||
// Create a new pipeline
|
||||
let pipeline = gst::Pipeline::new();
|
||||
|
||||
// Create elements for the pipeline
|
||||
let src = gst::ElementFactory::make("videotestsrc").build().unwrap();
|
||||
let sink = gst::ElementFactory::make("autovideosink").build().unwrap();
|
||||
|
||||
// Add elements to the pipeline
|
||||
pipeline.add_many(&[&src, &sink]).unwrap();
|
||||
|
||||
// Link elements together
|
||||
src.link(&sink).unwrap();
|
||||
|
||||
// Set the pipeline to the playing state
|
||||
pipeline.set_state(gst::State::Playing).unwrap();
|
||||
|
||||
// Start the main event loop
|
||||
// let main_loop = glib::MainLoop::new(None, false);
|
||||
// main_loop.run();
|
||||
// Shut down the pipeline and GStreamer
|
||||
let bus = pipeline.bus().unwrap();
|
||||
let messages = bus.iter_timed(gst::ClockTime::NONE);
|
||||
for msg in messages {
|
||||
dbg!(msg);
|
||||
}
|
||||
pipeline.set_state(gst::State::Null).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user