forked from mirrors/gstreamer-rs
examples: Separate common windowing logic from glupload
This allows to implement more GL-based examples reusing the same pipeline and rendering logic.
This commit is contained in:
parent
bf1941beee
commit
430d89539e
3 changed files with 20 additions and 17 deletions
|
@ -158,7 +158,7 @@ name = "ges"
|
||||||
required-features = ["ges"]
|
required-features = ["ges"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "glupload"
|
name = "glwindow"
|
||||||
required-features = ["gl"]
|
required-features = ["gl"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
16
examples/src/bin/glwindow.rs
Normal file
16
examples/src/bin/glwindow.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#[path = "../glupload.rs"]
|
||||||
|
mod glupload;
|
||||||
|
use glupload::*;
|
||||||
|
|
||||||
|
#[path = "../examples-common.rs"]
|
||||||
|
pub mod examples_common;
|
||||||
|
|
||||||
|
fn example_main() {
|
||||||
|
App::new()
|
||||||
|
.and_then(main_loop)
|
||||||
|
.unwrap_or_else(|e| eprintln!("Error! {}", e))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
examples_common::run(example_main);
|
||||||
|
}
|
|
@ -17,9 +17,6 @@ use std::sync;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::{Display, Error};
|
||||||
|
|
||||||
#[path = "../examples-common.rs"]
|
|
||||||
mod examples_common;
|
|
||||||
|
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Display, Error)]
|
||||||
#[display(fmt = "Missing element {}", _0)]
|
#[display(fmt = "Missing element {}", _0)]
|
||||||
struct MissingElement(#[error(not(source))] &'static str);
|
struct MissingElement(#[error(not(source))] &'static str);
|
||||||
|
@ -319,7 +316,7 @@ enum Message {
|
||||||
BusEvent,
|
BusEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct App {
|
pub(crate) struct App {
|
||||||
pipeline: gst::Pipeline,
|
pipeline: gst::Pipeline,
|
||||||
appsink: gst_app::AppSink,
|
appsink: gst_app::AppSink,
|
||||||
glupload: gst::Element,
|
glupload: gst::Element,
|
||||||
|
@ -330,7 +327,7 @@ struct App {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
fn new() -> Result<App, Error> {
|
pub(crate) fn new() -> Result<App, Error> {
|
||||||
gst::init()?;
|
gst::init()?;
|
||||||
|
|
||||||
let (pipeline, appsink, glupload) = App::create_pipeline()?;
|
let (pipeline, appsink, glupload) = App::create_pipeline()?;
|
||||||
|
@ -605,7 +602,7 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_loop(app: App) -> Result<(), Error> {
|
pub(crate) fn main_loop(app: App) -> Result<(), Error> {
|
||||||
app.setup(&app.event_loop)?;
|
app.setup(&app.event_loop)?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
@ -700,13 +697,3 @@ fn main_loop(app: App) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn example_main() {
|
|
||||||
App::new()
|
|
||||||
.and_then(main_loop)
|
|
||||||
.unwrap_or_else(|e| eprintln!("Error! {}", e))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
examples_common::run(example_main);
|
|
||||||
}
|
|
Loading…
Reference in a new issue