Compare commits

..

2 commits

Author SHA1 Message Date
Nickiel12
6ab27127bf stuff 2024-08-17 20:10:37 +00:00
Nickiel12
cf4cf3feb9 resolved merge 2024-08-17 20:10:19 +00:00
8 changed files with 907 additions and 2441 deletions

View file

@ -1,5 +0,0 @@
{
"rust-analyzer.linkedProjects": [
"./helloworld/Cargo.toml",
]
}

3147
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -9,24 +9,18 @@ edition = "2021"
anyhow = "1.0.86" anyhow = "1.0.86"
config = "0.14.0" config = "0.14.0"
ctrlc = "3.4.4" ctrlc = "3.4.4"
gst-plugin-webrtc = { version = "0.13.0", features = ["v1_22"] }
gst-plugin-webrtchttp = "0.13.0" gstreamer = { version = "0.23.0", features = ["v1_22"] }
gst-plugin-rtp = "0.13.0" gstreamer-app = { version = "0.23.0", features = ["v1_22"] }
gst-plugin-rtsp = "0.13.0"
gst-plugin-hlssink3 = "0.13.0"
gst-plugin-reqwest = "0.13.0"
gstreamer = { version = "0.23.0", features = ["v1_24"] }
gstreamer-webrtc = { version = "0.23.0", features = ["v1_22"] }
lazy_static = "1.5.0"
log = "0.4.22" log = "0.4.22"
serde = { version = "1.0.204", features = ["derive"] } serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.122" serde_json = "1.0.122"
snafu = "0.8.4" snafu = "0.8.4"
# tokio = "1.39.2" tokio = "1.39.2"
# tokio-tungstenite = "0.23.1" tokio-tungstenite = "0.23.1"
toml = "0.8.19" toml = "0.8.19"
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = "0.3.18" tracing-subscriber = "0.3.18"
tungstenite = "0.23.0" webrtc = "0.11.0"
vcs-common = { git = "https://git.nickiel.net/VCC/vcs-common.git", branch = "main" }

View file

@ -1,9 +0,0 @@
webrtcAdditionalHosts: [localhost, 0.0.0.0, 127.0.0.1, 10.0.0.114]
logLevel: debug
webrtcLocalTCPAddress: :8188
api: yes
paths:
mystream:
source: publisher

View file

@ -1,13 +0,0 @@
api: no
apiAddress: :9997
apiEncryption: no
paths:
mystream:
source: publisher
webrtc: yes
webrtcAddress: :8889
webrtcLocalUDPAddress: :8189
webrtcEncryption: no

View file

@ -2,12 +2,8 @@ use std::sync::{atomic::AtomicBool, Arc};
use anyhow::Error; use anyhow::Error;
use gstreamer::{prelude::*, Element, ElementFactory, Pipeline, State}; use gstreamer::{prelude::*, Element, ElementFactory, Pipeline, State};
use gstrswebrtc::{signaller::Signallable, webrtcsink};
mod config; mod config;
mod signaller;
use signaller::{SignallerEvent, SENDER_CHANNEL};
fn main() -> Result<(), Error> { fn main() -> Result<(), Error> {
// TRACING SETUP // TRACING SETUP
@ -18,10 +14,6 @@ fn main() -> Result<(), Error> {
let config = config::load_config(); let config = config::load_config();
let (sender, receiver) = std::sync::mpsc::channel::<SignallerEvent>();
*SENDER_CHANNEL.lock().unwrap() = Some(sender.clone());
// EXIT HANDLER // EXIT HANDLER
let to_quit = Arc::new(AtomicBool::new(false)); let to_quit = Arc::new(AtomicBool::new(false));
let to_quit_2 = to_quit.clone(); let to_quit_2 = to_quit.clone();
@ -32,6 +24,7 @@ fn main() -> Result<(), Error> {
// GSTREAMER SETUP // GSTREAMER SETUP
gstreamer::init()?; gstreamer::init()?;
<<<<<<< HEAD
gstrswebrtc::plugin_register_static()?; gstrswebrtc::plugin_register_static()?;
gstrsrtp::plugin_register_static()?; gstrsrtp::plugin_register_static()?;
@ -82,6 +75,20 @@ fn main() -> Result<(), Error> {
gstreamer::ClockTime::NONE, gstreamer::ClockTime::NONE,
&[gstreamer::MessageType::Eos] &[gstreamer::MessageType::Eos]
); );
=======
loop {
if to_quit.load(std::sync::atomic::Ordering::SeqCst) {
println!("Recieved Ctrl+C, stopping");
break;
}
std::thread::sleep(std::time::Duration::from_millis(200));
}
>>>>>>> 29a8ccf (added vcs-common)
println!("Success!"); println!("Success!");

View file

@ -1,110 +0,0 @@
use std::sync::Mutex;
use gstreamer::glib;
use gstreamer::subclass::prelude::*;
use gstreamer_webrtc::WebRTCSessionDescription;
use gstrswebrtc::signaller::{Signallable, SignallableImpl};
use lazy_static::lazy_static;
use std::sync::mpsc::Sender;
use tracing::error;
lazy_static! {
pub static ref SENDER_CHANNEL: Mutex<Option<Sender<SignallerEvent>>> = Mutex::new(None);
}
pub enum SignallerEvent {
Start,
Stop,
SendSDP(SdpMessage),
AddICE(ICE),
End(String),
}
pub struct ICE {
pub session_id: String,
pub candidate: String,
pub sdp_m_line_index: u32,
}
pub enum SdpMessage {
Offer(String),
Answer(String),
}
#[derive(Default)]
pub struct Signaller {}
impl Signaller {}
impl SignallableImpl for Signaller {
fn start(&self) {
SENDER_CHANNEL.lock().unwrap().as_ref().map(|msg_bus| {
if let Err(e) = msg_bus.send(SignallerEvent::Start) {
error!("Could not send message from the signaller to the message bus! {e}");
}
});
}
fn stop(&self) {
SENDER_CHANNEL.lock().unwrap().as_ref().map(|msg_bus| {
if let Err(e) = msg_bus.send(SignallerEvent::Stop) {
error!("Could not send message from the signaller to the message bus! {e}");
}
});
}
fn send_sdp(&self, _session_id: &str, sdp: &WebRTCSessionDescription) {
let message = {
if sdp.type_() == gstreamer_webrtc::WebRTCSDPType::Offer {
SdpMessage::Offer(sdp.sdp().as_text().unwrap())
} else {
SdpMessage::Answer(sdp.sdp().as_text().unwrap())
}
};
SENDER_CHANNEL.lock().unwrap().as_ref().map(|msg_bus| {
if let Err(e) = msg_bus.send(SignallerEvent::SendSDP(message)) {
error!("Could not send message from the signaller to the message bus! {e}");
}
});
}
fn add_ice(
&self,
session_id: &str,
candidate: &str,
sdp_m_line_index: u32,
_sdp_mid: Option<String>,
) {
let ice_msg = ICE {
session_id: session_id.to_string(),
candidate: candidate.to_string(),
sdp_m_line_index,
};
SENDER_CHANNEL.lock().unwrap().as_ref().map(|msg_bus| {
if let Err(e) = msg_bus.send(SignallerEvent::AddICE(ice_msg)) {
error!("Could not send message from the signaller to the message bus! {e}");
}
});
}
fn end_session(&self, sess_id: &str) {
let session_id = sess_id.to_string();
SENDER_CHANNEL.lock().unwrap().as_ref().map(|msg_bus| {
if let Err(e) = msg_bus.send(SignallerEvent::End(session_id)) {
error!("Could not send message from the signaller to the message bus! {e}");
}
});
}
}
#[glib::object_subclass]
impl ObjectSubclass for Signaller {
const NAME: &'static str = "MyCustomWebRTCSinkSignaller";
type Type = super::MyCustomSignaller;
type ParentType = glib::Object;
type Interfaces = (Signallable,);
}
impl ObjectImpl for Signaller {}

View file

@ -1,21 +0,0 @@
use gstreamer::glib;
use gstrswebrtc::signaller::Signallable;
mod imp;
pub use imp::{SdpMessage, SignallerEvent, ICE, SENDER_CHANNEL};
glib::wrapper! {
pub struct MyCustomSignaller(ObjectSubclass<imp::Signaller>) @implements Signallable;
}
impl MyCustomSignaller {
pub fn new() -> Self {
glib::Object::new()
}
}
impl Default for MyCustomSignaller {
fn default() -> Self {
MyCustomSignaller::new()
}
}