-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: switching to sans-io-runtime (#257)
This PR switched to use sans-io architecture with sans-io-runtime instead of async-runtime. The main reason is for performance and simplicity in data flow, everything will be sync now, make it easier for predicting time consume
- Loading branch information
Showing
287 changed files
with
6,049 additions
and
28,398 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
[workspace] | ||
members = [ | ||
"packages/cluster", | ||
"packages/endpoint", | ||
"packages/transport", | ||
"packages/audio-mixer", | ||
"packages/media-utils", | ||
"bin", | ||
"packages/protocol", | ||
"transports/webrtc", | ||
"transports/rtmp", | ||
"transports/sip", | ||
"servers/media-server" | ||
"packages/media_utils", | ||
"packages/media_core", | ||
"packages/media_runner", | ||
"packages/transport_webrtc", | ||
] | ||
|
||
[workspace.dependencies] | ||
futures = "0.3" | ||
async-trait = "0.1" | ||
async-std = { version = "1.12", features = ["tokio1", "unstable", "attributes"] } | ||
async-notify = "0.3" | ||
parking_lot = "0.12" | ||
log = { version = "0.4" } | ||
env_logger = { version = "0.11" } | ||
serde_json = "1.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
prost = "0.12" | ||
poem-openapi = { version = "4.0" } | ||
derive_more = { version = "0.99" } | ||
sans-io-runtime = { git = "https://github.com/giangndm/sans-io-runtime.git", rev = "9d16b9c224c2d1cd3015c9a2e60f51914c9bd880" } | ||
atm0s-sdn = { git = "https://github.com/giangndm/8xFF-decentralized-sdn.git", rev = "3c2945754926bd014c36e8ec20c228051a45603f" } | ||
convert-enum = "0.1" | ||
num_enum = "0.7" | ||
log = "0.4" | ||
smallmap = "1.4" | ||
derivative = "2.2" | ||
derive_more = "0.99" | ||
rand = "0.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "bin" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
tracing-subscriber = { version = "0.3", features = ["env-filter", "std"] } | ||
clap = { version = "4.5", features = ["env", "derive"] } | ||
log = { workspace = true } | ||
rand = { workspace = true } | ||
poem = { version = "3.0", features = ["static-files"] } | ||
poem-openapi = { version = "5.0", features = ["swagger-ui"] } | ||
tokio = { version = "1.37", features = ["full"] } | ||
sans-io-runtime = { workspace = true } | ||
atm0s-sdn = { workspace = true } | ||
media-server-protocol = { path = "../packages/protocol" } | ||
media-server-runner = { path = "../packages/media_runner" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<div> | ||
<a href="whip/index.html">Whip broadcast</a> | ||
</div> | ||
<div> | ||
<a href="whep/index.html">Whep viewer</a> | ||
</div> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...s/media-server/public/webrtc/whip/whip.js → bin/public/whip/whip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
//import { EventEmitter } from "events"; | ||
|
||
export class WHIPClient | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use std::net::SocketAddr; | ||
|
||
use media_server_protocol::endpoint::ClusterConnId; | ||
use media_server_protocol::transport::{RpcReq, RpcRes}; | ||
use poem::endpoint::StaticFilesEndpoint; | ||
use poem::{listener::TcpListener, middleware::Cors, EndpointExt, Route, Server}; | ||
use poem_openapi::types::{ToJSON, Type}; | ||
use poem_openapi::OpenApiService; | ||
use poem_openapi::{types::ParseFromJSON, Object}; | ||
use tokio::sync::mpsc::Sender; | ||
|
||
#[derive(Debug, Default, Object)] | ||
pub struct Response<T: ParseFromJSON + ToJSON + Type + Send + Sync> { | ||
pub status: bool, | ||
#[oai(skip_serializing_if = "Option::is_none")] | ||
pub error: Option<String>, | ||
#[oai(skip_serializing_if = "Option::is_none")] | ||
pub data: Option<T>, | ||
} | ||
|
||
pub struct Rpc<Req, Res> { | ||
pub req: Req, | ||
pub answer_tx: tokio::sync::oneshot::Sender<Res>, | ||
} | ||
|
||
impl<Req, Res> Rpc<Req, Res> { | ||
pub fn new(req: Req) -> (Self, tokio::sync::oneshot::Receiver<Res>) { | ||
let (answer_tx, answer_rx) = tokio::sync::oneshot::channel(); | ||
(Self { req, answer_tx }, answer_rx) | ||
} | ||
|
||
pub fn res(self, res: Res) { | ||
let _ = self.answer_tx.send(res); | ||
} | ||
} | ||
|
||
mod api_connector; | ||
mod api_media; | ||
mod utils; | ||
|
||
pub async fn run_gateway_http_server(sender: Sender<Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>) -> Result<(), Box<dyn std::error::Error>> { | ||
let api_service: OpenApiService<_, ()> = OpenApiService::new(api_media::MediaApis, "Media Gateway APIs", env!("CARGO_PKG_VERSION")).server("/"); | ||
let ui = api_service.swagger_ui(); | ||
let spec = api_service.spec(); | ||
let route = Route::new() | ||
.nest("/", api_service) | ||
.nest("/ui", ui) | ||
.at("/spec", poem::endpoint::make_sync(move |_| spec.clone())) | ||
.with(Cors::new()) | ||
.data(api_media::MediaServerCtx { sender }); | ||
|
||
Server::new(TcpListener::bind("0.0.0.0:3000")).run(route).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn run_media_http_server(port: u16, sender: Sender<Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>) -> Result<(), Box<dyn std::error::Error>> { | ||
let api_service: OpenApiService<_, ()> = OpenApiService::new(api_media::MediaApis, "Media Server APIs", env!("CARGO_PKG_VERSION")).server("/"); | ||
let ui = api_service.swagger_ui(); | ||
let spec = api_service.spec(); | ||
let route = Route::new() | ||
.nest("/", api_service) | ||
.nest("/samples", StaticFilesEndpoint::new("./public").index_file("index.html")) | ||
.nest("/ui", ui) | ||
.at("/spec", poem::endpoint::make_sync(move |_| spec.clone())) | ||
.with(Cors::new()) | ||
.data(api_media::MediaServerCtx { sender }); | ||
|
||
Server::new(TcpListener::bind(SocketAddr::new([0, 0, 0, 0].into(), port))).run(route).await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Oops, something went wrong.