mirror of
https://github.com/nestriness/warp.git
synced 2025-12-13 02:15:42 +02:00
Add async
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
|
use gst::glib;
|
||||||
|
use gst::glib::once_cell::sync::Lazy;
|
||||||
|
use tokio::runtime;
|
||||||
|
|
||||||
mod moqsink;
|
mod moqsink;
|
||||||
mod relayurl;
|
mod relayurl;
|
||||||
use gst::glib;
|
|
||||||
|
|
||||||
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
||||||
moqsink::register(plugin)?;
|
moqsink::register(plugin)?;
|
||||||
@@ -17,4 +20,13 @@ gst::plugin_define!(
|
|||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
env!("CARGO_PKG_REPOSITORY"),
|
env!("CARGO_PKG_REPOSITORY"),
|
||||||
env!("BUILD_REL_DATE")
|
env!("BUILD_REL_DATE")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//TODO: https://github.com/sdroege/gst-plugin-rs/blob/1faef49b51746a82c5b99a09a1034220cf92af9d/net/webrtc/src/lib.rs#L44C1-L50C4
|
||||||
|
pub static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
|
||||||
|
runtime::Builder::new_multi_thread()
|
||||||
|
.enable_all()
|
||||||
|
.worker_threads(1)
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
@@ -8,6 +8,8 @@ use std::sync::Mutex;
|
|||||||
|
|
||||||
use crate::relayurl::*;
|
use crate::relayurl::*;
|
||||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use moq_transport::cache::{broadcast, fragment, segment, track};
|
use moq_transport::cache::{broadcast, fragment, segment, track};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@@ -117,6 +119,38 @@ impl MoqSink {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// // Initialize shared state and channels
|
||||||
|
// let (sender, receiver) = mpsc::channel(32);
|
||||||
|
// // self.sender = Some(sender);
|
||||||
|
|
||||||
|
// // Spawn a new thread to run the Tokio runtime
|
||||||
|
// std::thread::spawn(move || {
|
||||||
|
// // Create a new Tokio runtime
|
||||||
|
// let rt = Runtime::new().unwrap();
|
||||||
|
|
||||||
|
// // Block on the async code within the Tokio runtime
|
||||||
|
// rt.block_on(async move {
|
||||||
|
// // Set up your async tasks here
|
||||||
|
// let session_task = session.run();
|
||||||
|
// let media_task = media.run();
|
||||||
|
|
||||||
|
// tokio::select! {
|
||||||
|
// res = session_task => {
|
||||||
|
// // Handle session result
|
||||||
|
// // You might want to send a message to the GStreamer element using the channel
|
||||||
|
// },
|
||||||
|
// res = media_task => {
|
||||||
|
// // Handle media result
|
||||||
|
// // You might want to send a message to the GStreamer element using the channel
|
||||||
|
// },
|
||||||
|
// msg = receiver.recv() => {
|
||||||
|
// // Handle messages sent from the GStreamer element to the Tokio runtime
|
||||||
|
// // These might be control commands or data to process
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,4 +339,4 @@ impl BaseSinkImpl for MoqSink {
|
|||||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||||
self.start()
|
self.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user