webrtcsink: Move RUNTIME to the crate so it can be reused

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/932>
This commit is contained in:
Thibault Saunier 2023-02-28 17:42:58 -03:00
parent 4ec441560b
commit 0ae637f531
4 changed files with 12 additions and 12 deletions

View file

@ -7,6 +7,8 @@
* Since: plugins-rs-0.9
*/
use gst::glib;
use tokio::runtime;
use once_cell::sync::Lazy;
mod signaller;
pub mod webrtcsink;
@ -28,3 +30,11 @@ gst::plugin_define!(
env!("CARGO_PKG_REPOSITORY"),
env!("BUILD_REL_DATE")
);
pub static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
runtime::Builder::new_multi_thread()
.enable_all()
.worker_threads(1)
.build()
.unwrap()
});

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
use crate::webrtcsink::{WebRTCSink, RUNTIME};
use crate::{webrtcsink::WebRTCSink, RUNTIME};
use anyhow::{anyhow, Error};
use async_tungstenite::tungstenite::Message as WsMessage;
use futures::channel::mpsc;

View file

@ -20,7 +20,7 @@ use std::sync::Mutex;
use super::homegrown_cc::CongestionController;
use super::{WebRTCSinkCongestionControl, WebRTCSinkError, WebRTCSinkMitigationMode};
use crate::signaller::Signaller;
use crate::webrtcsink::RUNTIME;
use crate::RUNTIME;
use std::collections::BTreeMap;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {

View file

@ -9,9 +9,7 @@
use gst::glib;
use gst::prelude::*;
use gst::subclass::prelude::*;
use once_cell::sync::Lazy;
use std::error::Error;
use tokio::runtime;
mod homegrown_cc;
mod imp;
@ -167,11 +165,3 @@ 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()
});