commit b9e1e34ca09f88e1ccf8f4f6dc15d04f59237ffb Author: Rafael Caricio Date: Sun Dec 27 16:14:50 2020 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c590f2e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "gst-rtmpsrv" +description = "GStreamer Plugin that creates a server that is capable of receiving a RTMP stream" +version = "0.1.0" +authors = ["Rafael Caricio "] +repository = "https://github.com/rafaelcaricio/gst-rtmpsrv" +edition = "2018" + +[lib] +name = "rtmpsrv" +crate-type = ["cdylib", "rlib", "staticlib"] +path = "src/lib.rs" + +[dependencies] +glib = { git = "https://github.com/gtk-rs/gtk-rs" } +gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_12"] } +gst-base = { package = "gstreamer-base", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_12"] } +gst-video = { package = "gstreamer-video", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_12"] } +gst-audio = { package = "gstreamer-audio", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_12"] } +once_cell = "1.0" + +[build-dependencies] +gst-plugin-version-helper = { git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs" } diff --git a/README.md b/README.md new file mode 100644 index 0000000..abab56d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# GStreamer RTMP Server Plugin + +GStreamer Plugin that creates a server that is capable of receiving a RTMP stream. diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..14232df --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + gst_plugin_version_helper::get_info(); +} diff --git a/src/imp.rs b/src/imp.rs new file mode 100644 index 0000000..948f58d --- /dev/null +++ b/src/imp.rs @@ -0,0 +1,62 @@ +use glib::subclass; +use glib::subclass::prelude::*; +use gst::prelude::*; +use gst::subclass::prelude::*; +use gst::{gst_debug, gst_error, gst_info, gst_log}; +use gst_base::prelude::*; +use gst_base::subclass::prelude::*; + +use once_cell::sync::Lazy; + +static CAT: Lazy = Lazy::new(|| { + gst::DebugCategory::new( + "rtmpsrvsrc", + gst::DebugColorFlags::empty(), + Some("RTMP Server Source"), + ) +}); + +pub struct RtmpSvrSrc { + +} + +impl ObjectSubclass for RtmpSvrSrc { + const NAME: &'static str = "RtmpSvrSrc"; + type Type = super::RtmpSrvSrc; + type ParentType = gst_base::PushSrc; + type Instance = gst::subclass::ElementInstanceStruct; + type Class = subclass::simple::ClassStruct; + + glib::object_subclass!(); + + fn class_init(klass: &mut Self::Class) { + klass.set_metadata( + "RTMP Server Source", + "Source/Video", + "Creates a server that is capable of receiving a RTMP stream", + "Rafael Caricio ", + ); + + let caps = gst::Caps::new_simple( + "video/x-raw", + &[], + ); + + let src_pad_template = gst::PadTemplate::new( + "src", + gst::PadDirection::Src, + gst::PadPresence::Always, + &caps, + ).unwrap(); + klass.add_pad_template(src_pad_template); + } + + fn new() -> Self { + Self {} + } +} + +impl ObjectImpl for RtmpSvrSrc {} +impl ElementImpl for RtmpSvrSrc {} +impl BaseSrcImpl for RtmpSvrSrc {} +impl PushSrcImpl for RtmpSvrSrc {} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..7eab5b5 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,33 @@ +use glib::prelude::*; + +mod imp; + +glib::wrapper! { + pub struct RtmpSrvSrc(ObjectSubclass) @extends gst_base::BaseSrc, gst::Element, gst::Object; +} + +unsafe impl Send for RtmpSrvSrc {} +unsafe impl Sync for RtmpSrvSrc {} + +pub fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { + gst::Element::register( + Some(plugin), + "rtmpsvrsrc", + gst::Rank::None, + RtmpSrvSrc::static_type(), + )?; + + Ok(()) +} + +gst::plugin_define!( + rtmpsrvsrc, + env!("CARGO_PKG_DESCRIPTION"), + plugin_init, + concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")), + "MIT/X11", + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_NAME"), + env!("CARGO_PKG_REPOSITORY"), + env!("BUILD_REL_DATE") +);