mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-10 18:14:15 +00:00
examples: webrtc: rust: Move from async-std to tokio
async-std is deprecated now and tokio is what effectively everybody is using by default nowadays. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8659>
This commit is contained in:
parent
fa63afba84
commit
0623581850
6 changed files with 470 additions and 1512 deletions
File diff suppressed because it is too large
Load diff
|
@ -4,13 +4,15 @@ version = "0.1.0"
|
|||
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3"
|
||||
async-std = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
rand = { version = "0.9", features = ["thread_rng"] }
|
||||
async-tungstenite = { version = "0.29", features = ["async-std-runtime", "async-native-tls"] }
|
||||
async-tungstenite = { version = "0.29", features = ["tokio-runtime", "tokio-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.23" }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.23" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.23" }
|
||||
|
|
|
@ -7,15 +7,10 @@ use rand::prelude::*;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use async_std::prelude::*;
|
||||
use async_std::task;
|
||||
use futures::channel::mpsc;
|
||||
use futures::sink::{Sink, SinkExt};
|
||||
use futures::stream::StreamExt;
|
||||
use futures::prelude::*;
|
||||
|
||||
use async_tungstenite::tungstenite;
|
||||
use tungstenite::Error as WsError;
|
||||
use tungstenite::Message as WsMessage;
|
||||
use async_tungstenite::tungstenite::{Error as WsError, Message as WsMessage};
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
|
@ -983,7 +978,7 @@ async fn async_main() -> Result<(), anyhow::Error> {
|
|||
let args = Args::parse();
|
||||
|
||||
// Connect to the given server
|
||||
let (mut ws, _) = async_tungstenite::async_std::connect_async(&args.server).await?;
|
||||
let (mut ws, _) = async_tungstenite::tokio::connect_async(&args.server).await?;
|
||||
|
||||
println!("connected");
|
||||
|
||||
|
@ -1041,5 +1036,8 @@ async fn async_main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
macos_workaround::run(|| task::block_on(async_main()))
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?;
|
||||
macos_workaround::run(move || runtime.block_on(async_main()))
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,11 +6,11 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
futures = "0.3"
|
||||
async-std = "1"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
rand = { version = "0.9", features = ["thread_rng"] }
|
||||
async-tungstenite = { version = "0.29", features = ["async-std-runtime", "async-native-tls"] }
|
||||
async-tungstenite = { version = "0.29", features = ["tokio-runtime", "tokio-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.23" }
|
||||
gst-rtp = { package = "gstreamer-rtp", version = "0.23", features = ["v1_20"] }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.23" }
|
||||
|
@ -21,3 +21,5 @@ serde_json = "1"
|
|||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
cocoa = "0.26"
|
||||
|
||||
[workspace]
|
||||
|
|
|
@ -6,15 +6,10 @@ use rand::prelude::*;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use async_std::prelude::*;
|
||||
use async_std::task;
|
||||
use futures::channel::mpsc;
|
||||
use futures::sink::{Sink, SinkExt};
|
||||
use futures::stream::StreamExt;
|
||||
use futures::prelude::*;
|
||||
|
||||
use async_tungstenite::tungstenite;
|
||||
use tungstenite::Error as WsError;
|
||||
use tungstenite::Message as WsMessage;
|
||||
use async_tungstenite::tungstenite::{Error as WsError, Message as WsMessage};
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
|
@ -756,7 +751,7 @@ async fn async_main() -> Result<(), anyhow::Error> {
|
|||
let args = Args::parse();
|
||||
|
||||
// Connect to the given server
|
||||
let (mut ws, _) = async_tungstenite::async_std::connect_async(&args.server).await?;
|
||||
let (mut ws, _) = async_tungstenite::tokio::connect_async(&args.server).await?;
|
||||
|
||||
println!("connected");
|
||||
|
||||
|
@ -806,5 +801,8 @@ async fn async_main() -> Result<(), anyhow::Error> {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
macos_workaround::run(|| task::block_on(async_main()))
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()?;
|
||||
macos_workaround::run(move || runtime.block_on(async_main()))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue