Skip to content

Commit

Permalink
feat: transport for SIP with rtpengine protocol (#359)
Browse files Browse the repository at this point in the history
* add rtp engine for voip

* add answer offer sdp with fixed

* create rtp internal process for transport

* add rtp parser packet

* rewrite sdp answer function

* add sample for sip drachtio

* add simple converter

* refactor ng-controller-server

* first working without transcode

* fixed warns

* fix deny with sdp-rs

* fix deny with sdp-rs

* added token secure

* added gateway proxy

* audio transcode

* fix warns

* fix typos

* update github action

* add SIP docs

---------

Co-authored-by: Giang Minh <[email protected]>
  • Loading branch information
marverlous811 and giangndm authored Jul 31, 2024
1 parent b63e5cf commit 69d6752
Show file tree
Hide file tree
Showing 52 changed files with 3,059 additions and 180 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ name: rust-clippy analyze

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: ["master"]
schedule:
- cron: '29 19 * * 2'
- cron: "29 19 * * 2"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -33,6 +33,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install deps
run: |
sudo apt-get update
sudo apt install -y libsoxr-dev libopus-dev libssl-dev
- uses: actions/cache@v3
id: cache-cargo
with:
Expand All @@ -48,15 +53,15 @@ jobs:
with:
version: "25.1"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run rust-clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt

- name: Run rust-sarif
run: cargo clippy --all-features --message-format=json |
run: cargo clippy --all-features --message-format=json |
clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt

- name: Upload analysis results to GitHub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install deps
run: |
sudo apt-get update
sudo apt install -y libsoxr-dev libopus-dev libssl-dev libfdk-aac-dev
sudo apt install -y libsoxr-dev libopus-dev libssl-dev
- uses: actions/cache@v3
with:
Expand Down
112 changes: 112 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ members = [
"packages/media_core",
"packages/media_runner",
"packages/transport_webrtc",
"packages/transport_rtpengine",
"packages/media_secure",
"packages/media_gateway",
"packages/audio_mixer", "packages/media_connector", "packages/media_record",
"packages/audio_mixer",
"packages/media_connector",
"packages/media_record",
"packages/media_codecs",
"packages/rtpengine_ngcontrol",
]

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ We are actively refactoring entire media server and network stack with [sans-io-
| WebRTC-SDK | Webrtc-SDK Protocol [RFC-0005](https://github.com/8xFF/rfcs/pull/5) | 🚀 |
| RTMP | RTMP Protocol ||
| RTMP-Transcode | RTMP with Transcode ||
| SIP | SIP calls | |
| SIP | SIP calls [Sip-call-sample](https://github.com/8xFF/atm0s-media-sip-call-sample) | 🚀 |
| MoQ | Media-over-Quic ||
| Monitoring | Dashboard for monitoring ||
| Recording | Record stream | 🚀 |
Expand Down
3 changes: 2 additions & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ media-server-gateway = { path = "../packages/media_gateway", optional = true }
media-server-connector = { path = "../packages/media_connector", optional = true }
media-server-record = { path = "../packages/media_record", default-features=false, optional = true }
media-server-utils = { path = "../packages/media_utils", optional = true }
rtpengine-ngcontrol = { path = "../packages/rtpengine_ngcontrol", optional = true }
local-ip-address = "0.6"
serde = { version = "1.0", features = ["derive"] }
quinn = { version = "0.11", optional = true }
Expand All @@ -40,7 +41,7 @@ mime_guess = { version = "2.0", optional = true }
[features]
default = ["console", "gateway", "media", "connector", "cert_utils"]
gateway = ["media-server-gateway", "media-server-connector", "quinn_vnet", "node_metrics", "maxminddb", "rust-embed"]
media = ["media-server-runner", "media-server-record", "quinn_vnet", "node_metrics"]
media = ["media-server-runner", "media-server-record", "quinn_vnet", "node_metrics", "rtpengine-ngcontrol"]
console = []
connector = ["quinn_vnet", "media-server-connector", "media-server-utils"]
cert_utils = ["rcgen", "rustls"]
Expand Down
21 changes: 2 additions & 19 deletions bin/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,6 @@ impl<T: ParseFromJSON + ToJSON + Type + Send + Sync> Default for Response<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)
}

#[allow(unused)]
pub fn res(self, res: Res) {
let _ = self.answer_tx.send(res);
}
}

#[cfg(feature = "console")]
pub async fn run_console_http_server(
port: u16,
Expand Down Expand Up @@ -128,7 +111,7 @@ pub async fn run_console_http_server(
#[cfg(feature = "gateway")]
pub async fn run_gateway_http_server<ES: 'static + MediaEdgeSecure + Send + Sync, GS: 'static + MediaGatewaySecure + Send + Sync>(
port: u16,
sender: Sender<Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>,
sender: Sender<crate::rpc::Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>,
edge_secure: Arc<ES>,
gateway_secure: Arc<GS>,
) -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -161,7 +144,7 @@ pub async fn run_gateway_http_server<ES: 'static + MediaEdgeSecure + Send + Sync
#[cfg(feature = "media")]
pub async fn run_media_http_server<ES: 'static + MediaEdgeSecure + Send + Sync, GS: 'static + MediaGatewaySecure + Send + Sync>(
port: u16,
sender: Sender<Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>,
sender: Sender<crate::rpc::Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>,
edge_secure: Arc<ES>,
gateway_secure: Option<Arc<GS>>,
) -> Result<(), Box<dyn std::error::Error>> {
Expand Down
7 changes: 3 additions & 4 deletions bin/src/http/api_media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ use poem_openapi::{
};
use rand::random;

use super::{
utils::{ApplicationSdp, ApplicationSdpPatch, CustomHttpResponse, Protobuf, RemoteIpAddr, TokenAuthorization, UserAgent},
Rpc,
};
use crate::rpc::Rpc;

use super::utils::{ApplicationSdp, ApplicationSdpPatch, CustomHttpResponse, Protobuf, RemoteIpAddr, TokenAuthorization, UserAgent};

pub struct MediaServerCtx<S: MediaEdgeSecure + Send + Sync> {
pub(crate) sender: tokio::sync::mpsc::Sender<Rpc<RpcReq<ClusterConnId>, RpcRes<ClusterConnId>>>,
Expand Down
Loading

0 comments on commit 69d6752

Please sign in to comment.