Write a demo app that plays the gstreamer test video

This commit is contained in:
Savanni D'Gerinel 2024-08-27 13:51:58 -04:00
parent f8fdaf2892
commit ee56513299
6 changed files with 1109 additions and 746 deletions

1779
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,16 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1704732714, "lastModified": 1724316499,
"narHash": "sha256-ABqK/HggMYA/jMUXgYyqVAcQ8QjeMyr1jcXfTpSHmps=", "narHash": "sha256-Qb9MhKBUTCfWg/wqqaxt89Xfi6qTD3XpTzQ9eXi3JmE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6723fa4e4f1a30d42a633bef5eb01caeb281adc3", "rev": "797f7dc49e0bc7fab4b57c021cdf68f595e47841",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-23.11", "ref": "nixos-24.05",
"type": "indirect" "type": "indirect"
} }
}, },

View File

@ -2,7 +2,7 @@
description = "Lumenescent Dreams Tools"; description = "Lumenescent Dreams Tools";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11"; nixpkgs.url = "nixpkgs/nixos-24.05";
unstable.url = "nixpkgs/nixos-unstable"; unstable.url = "nixpkgs/nixos-unstable";
typeshare.url = "github:1Password/typeshare"; typeshare.url = "github:1Password/typeshare";
}; };
@ -30,6 +30,9 @@
pkgs.gst_all_1.gst-plugins-good pkgs.gst_all_1.gst-plugins-good
pkgs.gst_all_1.gst-plugins-ugly pkgs.gst_all_1.gst-plugins-ugly
pkgs.gst_all_1.gstreamer pkgs.gst_all_1.gstreamer
pkgs.gst_all_1.gstreamer.dev
pkgs.gst_all_1.gst-libav
pkgs.gst_all_1.gst-vaapi
pkgs.gtk4 pkgs.gtk4
pkgs.libadwaita pkgs.libadwaita
pkgs.librsvg pkgs.librsvg

View File

@ -6,8 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
pipewire = "0.8.0" gstreamer = { version = "0.23.0", features = ["serde", "v1_24"] }
serde = { version = "1.0.209", features = ["alloc", "derive"] } pipewire = { version = "0.8.0" }
serde_json = "1.0.127" serde = { version = "1.0.209", features = ["alloc", "derive"] }
tokio = { version = "1.39.3", features = ["full"] } serde_json = { version = "1.0.127" }
warp = "0.3.7" tokio = { version = "1.39.3", features = ["full"] }
warp = { version = "0.3.7" }
glib = { version = "0.18" }

View File

@ -0,0 +1,49 @@
use gstreamer::prelude::*;
use pipewire::{context::Context, main_loop::MainLoop};
fn main() {
gstreamer::init();
// let srcfactory = gstreamer::ElementFactory::find("filesrc").unwrap().load().unwrap();
let srcfactory = gstreamer::ElementFactory::find("videotestsrc")
.unwrap()
.load()
.unwrap();
let sinkfactory = gstreamer::ElementFactory::find("autovideosink")
.unwrap()
.load()
.unwrap();
let video_effect = gstreamer::ElementFactory::find("vertigotv")
.unwrap()
.load()
.unwrap();
println!("source factory type: {:?}", srcfactory.element_type());
println!("sink factory type: {:?}", sinkfactory.element_type());
println!("video factory type: {:?}", video_effect.element_type());
let source = srcfactory.create().name("source").build().unwrap();
let sink = sinkfactory.create().name("sink").build().unwrap();
let filter = video_effect.create().name("filter").build().unwrap();
// let source = gstreamer::ElementFactory::make("videotestsrc");
// let sink = gstreamer::ElementFactory::make("autovideosink");
let pipeline = gstreamer::Pipeline::new();
pipeline.add(&source).unwrap();
pipeline.add(&sink).unwrap();
pipeline.add(&filter).unwrap();
source.link(&filter).unwrap();
filter.link(&sink).unwrap();
pipeline.set_state(gstreamer::State::Playing).unwrap();
let bus = pipeline.bus().unwrap();
let msg = bus.timed_pop_filtered(
gstreamer::ClockTime::NONE,
&[gstreamer::MessageType::Error, gstreamer::MessageType::Eos],
);
println!("message: {:?}", msg);
pipeline.set_state(gstreamer::State::Null);
}

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "1.77.0" channel = "1.80.1"
targets = [ "wasm32-unknown-unknown", "thumbv6m-none-eabi" ] targets = [ "wasm32-unknown-unknown", "thumbv6m-none-eabi" ]