webrtc: Share runtime between webrtcsink and signaller crates

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1019>
This commit is contained in:
Zhao, Gang 2022-12-17 20:53:41 +08:00 committed by GStreamer Marge Bot
parent 1ffeb4d44d
commit 877a9bd7f3
3 changed files with 12 additions and 19 deletions

View file

@ -1,8 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use crate::webrtcsink::WebRTCSink;
use crate::webrtcsink::{RUNTIME, WebRTCSink};
use anyhow::{anyhow, Error};
use tokio::runtime;
use tokio::task;
use async_tungstenite::tungstenite::Message as WsMessage;
use futures::channel::mpsc;
@ -25,14 +24,6 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
)
});
static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap()
});
#[derive(Default)]
struct State {
/// Sender for the websocket messages

View file

@ -9,7 +9,6 @@ use gst_utils::StreamProducer;
use gst_video::subclass::prelude::*;
use gst_webrtc::WebRTCDataChannel;
use tokio::runtime;
use futures::prelude::*;
use anyhow::{anyhow, Error};
@ -20,6 +19,7 @@ use std::sync::Mutex;
use super::homegrown_cc::CongestionController;
use super::{WebRTCSinkCongestionControl, WebRTCSinkError, WebRTCSinkMitigationMode};
use crate::webrtcsink::RUNTIME;
use crate::signaller::Signaller;
use std::collections::BTreeMap;
@ -31,14 +31,6 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
)
});
static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap()
});
const CUDA_MEMORY_FEATURE: &str = "memory:CUDAMemory";
const GL_MEMORY_FEATURE: &str = "memory:GLMemory";
const NVMM_MEMORY_FEATURE: &str = "memory:NVMM";

View file

@ -10,6 +10,8 @@ use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use std::error::Error;
use tokio::runtime;
use once_cell::sync::Lazy;
mod homegrown_cc;
mod imp;
@ -165,3 +167,11 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
WebRTCSink::static_type(),
)
}
pub static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap()
});