Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rtp transport #424

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

108 changes: 96 additions & 12 deletions bin/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,42 @@
let token_service: OpenApiService<_, ()> = OpenApiService::new(api_token::TokenApis::<GS>::new(), "App APIs", env!("CARGO_PKG_VERSION")).server("/token/");
let token_ui = token_service.swagger_ui();
let token_spec = token_service.spec();
let media_service: OpenApiService<_, ()> = OpenApiService::new(api_media::MediaApis::<ES>::new(), "Media Gateway APIs", env!("CARGO_PKG_VERSION")).server("/media/");
let media_ui = media_service.swagger_ui();
let media_spec = media_service.spec();

let webrtc_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WebrtcApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Webrtc Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/webrtc/");
let webrtc_ui = webrtc_service.swagger_ui();
let webrtc_spec = webrtc_service.spec();

let whip_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WhipApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Whip Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/whip/");
let whip_ui = whip_service.swagger_ui();
let whip_spec = whip_service.spec();

let whep_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WhepApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Whep Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/whep/");
let whep_ui = whep_service.swagger_ui();
let whep_spec = whep_service.spec();

let rtpengine_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::RtpengineApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media RtpEngine Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/rtpengine/");
let rtpengine_ui = rtpengine_service.swagger_ui();
let rtpengine_spec = rtpengine_service.spec();

Check warning on line 156 in bin/src/http.rs

View check run for this annotation

Codecov / codecov/patch

bin/src/http.rs#L121-L156

Added lines #L121 - L156 were not covered by tests

#[cfg(not(feature = "embed_static"))]
let samples = StaticFilesEndpoint::new("./public/media/").index_file("index.html");
Expand All @@ -132,9 +165,18 @@
.nest("/token/", token_service.data(api_token::TokenServerCtx { secure: gateway_secure }))
.nest("/token/ui", token_ui)
.at("/token/spec", poem::endpoint::make_sync(move |_| token_spec.clone()))
.nest("/", media_service.data(api_media::MediaServerCtx { sender, secure: edge_secure }))
.nest("/ui", media_ui)
.at("/spec", poem::endpoint::make_sync(move |_| media_spec.clone()))
.nest("/webrtc/", webrtc_service)
.nest("/webrtc/ui", webrtc_ui)
.at("/webrtc/spec", poem::endpoint::make_sync(move |_| webrtc_spec.clone()))
.nest("/whip/", whip_service)
.nest("/whip/ui", whip_ui)
.at("/whip/spec", poem::endpoint::make_sync(move |_| whip_spec.clone()))
.nest("/whep/", whep_service)
.nest("/whep/ui", whep_ui)
.at("/whep/spec", poem::endpoint::make_sync(move |_| whep_spec.clone()))
.nest("/rtpengine/", rtpengine_service)
.nest("/rtpengine/ui", rtpengine_ui)
.at("/rtpengine/spec", poem::endpoint::make_sync(move |_| rtpengine_spec.clone()))

Check warning on line 179 in bin/src/http.rs

View check run for this annotation

Codecov / codecov/patch

bin/src/http.rs#L168-L179

Added lines #L168 - L179 were not covered by tests
.with(Cors::new());

Server::new(TcpListener::bind(SocketAddr::new([0, 0, 0, 0].into(), port))).run(route).await?;
Expand All @@ -159,9 +201,42 @@
.nest("/token/ui", token_ui)
.at("/token/spec", poem::endpoint::make_sync(move |_| token_spec.clone()));
}
let media_service: OpenApiService<_, ()> = OpenApiService::new(api_media::MediaApis::<ES>::new(), "Media Gateway APIs", env!("CARGO_PKG_VERSION")).server("/media/");
let media_ui = media_service.swagger_ui();
let media_spec = media_service.spec();

let webrtc_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WebrtcApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Webrtc Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/webrtc/");
let webrtc_ui = webrtc_service.swagger_ui();
let webrtc_spec = webrtc_service.spec();

let whip_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WhipApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Whip Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/whip/");
let whip_ui = whip_service.swagger_ui();
let whip_spec = whip_service.spec();

let whep_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::WhepApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media Whep Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/whep/");
let whep_ui = whep_service.swagger_ui();
let whep_spec = whep_service.spec();

let rtpengine_service: OpenApiService<_, ()> = OpenApiService::new(
api_media::RtpengineApis::<ES>::new(sender.clone(), edge_secure.clone()),
"Media RtpEngine Gateway APIs",
env!("CARGO_PKG_VERSION"),
)
.server("/rtpengine/");
let rtpengine_ui = rtpengine_service.swagger_ui();
let rtpengine_spec = rtpengine_service.spec();

Check warning on line 239 in bin/src/http.rs

View check run for this annotation

Codecov / codecov/patch

bin/src/http.rs#L205-L239

Added lines #L205 - L239 were not covered by tests

#[cfg(not(feature = "embed_static"))]
let samples = StaticFilesEndpoint::new("./public/media/").index_file("index.html");
Expand All @@ -170,9 +245,18 @@

let route = route
.nest("/samples", samples)
.nest("/", media_service.data(api_media::MediaServerCtx { sender, secure: edge_secure }))
.nest("/ui", media_ui)
.at("/spec", poem::endpoint::make_sync(move |_| media_spec.clone()))
.nest("/webrtc/", webrtc_service)
.nest("/webrtc/ui", webrtc_ui)
.at("/webrtc/spec", poem::endpoint::make_sync(move |_| webrtc_spec.clone()))
.nest("/whip/", whip_service)
.nest("/whip/ui", whip_ui)
.at("/whip/spec", poem::endpoint::make_sync(move |_| whip_spec.clone()))
.nest("/whep/", whep_service)
.nest("/whep/ui", whep_ui)
.at("/whep/spec", poem::endpoint::make_sync(move |_| whep_spec.clone()))
.nest("/rtpengine/", rtpengine_service)
.nest("/rtpengine/ui", rtpengine_ui)
.at("/rtpengine/spec", poem::endpoint::make_sync(move |_| rtpengine_spec.clone()))

Check warning on line 259 in bin/src/http.rs

View check run for this annotation

Codecov / codecov/patch

bin/src/http.rs#L248-L259

Added lines #L248 - L259 were not covered by tests
.with(Cors::new());

Server::new(TcpListener::bind(SocketAddr::new([0, 0, 0, 0].into(), port))).run(route).await?;
Expand Down
Loading
Loading