diff --git a/src/description/config.rs b/src/configs/media_config.rs similarity index 99% rename from src/description/config.rs rename to src/configs/media_config.rs index 8a617e0..5cfa3e9 100644 --- a/src/description/config.rs +++ b/src/configs/media_config.rs @@ -6,17 +6,16 @@ use crate::description::{ RTPCodecType, }, rtp_extensions_from_media_description, - rtp_transceiver::TYPE_RTCP_FB_TRANSPORT_CC, + rtp_transceiver::{PayloadType, RTCPFeedback, TYPE_RTCP_FB_TRANSPORT_CC}, rtp_transceiver_direction::RTCRtpTransceiverDirection, - PayloadType, RTCPFeedback, }; //TODO: use crate::stats::stats_collector::StatsCollector; //use crate::stats::CodecStats; //use crate::stats::StatsReportType::Codec; -use crate::interceptor::report::receiver_report::ReceiverReport; -use crate::interceptor::report::sender_report::SenderReport; -use crate::interceptor::Registry; +use crate::interceptors::report::receiver_report::ReceiverReport; +use crate::interceptors::report::sender_report::SenderReport; +use crate::interceptors::Registry; use sdp::description::session::SessionDescription; use shared::error::{Error, Result}; use std::collections::HashMap; diff --git a/src/configs/mod.rs b/src/configs/mod.rs new file mode 100644 index 0000000..5e1b239 --- /dev/null +++ b/src/configs/mod.rs @@ -0,0 +1,3 @@ +pub(crate) mod media_config; +pub(crate) mod server_config; +pub(crate) mod session_config; diff --git a/src/server/config.rs b/src/configs/server_config.rs similarity index 97% rename from src/server/config.rs rename to src/configs/server_config.rs index b1ad4ff..e7df2a2 100644 --- a/src/server/config.rs +++ b/src/configs/server_config.rs @@ -1,4 +1,4 @@ -use crate::description::config::MediaConfig; +use crate::configs::media_config::MediaConfig; use crate::server::certificate::RTCCertificate; use std::sync::Arc; use std::time::Duration; diff --git a/src/session/config.rs b/src/configs/session_config.rs similarity index 88% rename from src/session/config.rs rename to src/configs/session_config.rs index c9bcbae..d0ed7e8 100644 --- a/src/session/config.rs +++ b/src/configs/session_config.rs @@ -1,4 +1,4 @@ -use crate::server::config::ServerConfig; +use crate::configs::server_config::ServerConfig; use std::net::SocketAddr; use std::sync::Arc; diff --git a/src/description/mod.rs b/src/description/mod.rs index c5c79e5..5079662 100644 --- a/src/description/mod.rs +++ b/src/description/mod.rs @@ -1,10 +1,10 @@ -pub(crate) mod config; pub(crate) mod fmtp; pub(crate) mod rtp_codec; pub(crate) mod rtp_transceiver; pub(crate) mod rtp_transceiver_direction; pub(crate) mod sdp_type; +use crate::configs::session_config::SessionConfig; use crate::description::{ rtp_codec::{RTCRtpCodecCapability, RTCRtpCodecParameters, RTCRtpHeaderExtensionParameters}, rtp_transceiver::{ @@ -15,7 +15,6 @@ use crate::description::{ }; use crate::endpoint::candidate::RTCIceParameters; use crate::server::certificate::RTCDtlsFingerprint; -use crate::session::config::SessionConfig; use crate::types::Mid; use sdp::description::common::{Address, ConnectionInformation}; use sdp::description::media::{MediaName, RangedPort}; diff --git a/src/description/rtp_codec.rs b/src/description/rtp_codec.rs index d4221e2..ccbd013 100644 --- a/src/description/rtp_codec.rs +++ b/src/description/rtp_codec.rs @@ -1,5 +1,5 @@ +use crate::configs::media_config::*; use crate::description::{ - config::*, fmtp, rtp_transceiver::{PayloadType, RTCPFeedback}, }; diff --git a/src/endpoint/mod.rs b/src/endpoint/mod.rs index b7c295b..4fcbf34 100644 --- a/src/endpoint/mod.rs +++ b/src/endpoint/mod.rs @@ -3,7 +3,7 @@ pub(crate) mod transport; use crate::description::{rtp_transceiver::RTCRtpTransceiver, RTCSessionDescription}; use crate::endpoint::transport::Transport; -use crate::interceptor::Interceptor; +use crate::interceptors::Interceptor; use crate::types::{EndpointId, FourTuple, Mid}; use std::collections::HashMap; diff --git a/src/handler/datachannel.rs b/src/handlers/datachannel.rs similarity index 100% rename from src/handler/datachannel.rs rename to src/handlers/datachannel.rs diff --git a/src/handler/demuxer.rs b/src/handlers/demuxer.rs similarity index 100% rename from src/handler/demuxer.rs rename to src/handlers/demuxer.rs diff --git a/src/handler/dtls.rs b/src/handlers/dtls.rs similarity index 100% rename from src/handler/dtls.rs rename to src/handlers/dtls.rs diff --git a/src/handler/exception.rs b/src/handlers/exception.rs similarity index 100% rename from src/handler/exception.rs rename to src/handlers/exception.rs diff --git a/src/handler/gateway.rs b/src/handlers/gateway.rs similarity index 100% rename from src/handler/gateway.rs rename to src/handlers/gateway.rs diff --git a/src/handler/interceptor.rs b/src/handlers/interceptor.rs similarity index 99% rename from src/handler/interceptor.rs rename to src/handlers/interceptor.rs index fc0dba3..e35be65 100644 --- a/src/handler/interceptor.rs +++ b/src/handlers/interceptor.rs @@ -1,4 +1,4 @@ -use crate::interceptor::InterceptorEvent; +use crate::interceptors::InterceptorEvent; use crate::messages::{MessageEvent, RTPMessageEvent, TaggedMessageEvent}; use crate::types::FourTuple; use crate::ServerStates; diff --git a/src/handler/mod.rs b/src/handlers/mod.rs similarity index 100% rename from src/handler/mod.rs rename to src/handlers/mod.rs diff --git a/src/handler/sctp.rs b/src/handlers/sctp.rs similarity index 100% rename from src/handler/sctp.rs rename to src/handlers/sctp.rs diff --git a/src/handler/srtp.rs b/src/handlers/srtp.rs similarity index 100% rename from src/handler/srtp.rs rename to src/handlers/srtp.rs diff --git a/src/handler/stun.rs b/src/handlers/stun.rs similarity index 100% rename from src/handler/stun.rs rename to src/handlers/stun.rs diff --git a/src/interceptor/mod.rs b/src/interceptors/mod.rs similarity index 100% rename from src/interceptor/mod.rs rename to src/interceptors/mod.rs diff --git a/src/interceptor/nack/mod.rs b/src/interceptors/nack/mod.rs similarity index 100% rename from src/interceptor/nack/mod.rs rename to src/interceptors/nack/mod.rs diff --git a/src/interceptor/report/mod.rs b/src/interceptors/report/mod.rs similarity index 95% rename from src/interceptor/report/mod.rs rename to src/interceptors/report/mod.rs index aa513a3..230f0a4 100644 --- a/src/interceptor/report/mod.rs +++ b/src/interceptors/report/mod.rs @@ -1,4 +1,4 @@ -use crate::interceptor::{Interceptor, InterceptorBuilder}; +use crate::interceptors::{Interceptor, InterceptorBuilder}; use std::collections::HashMap; use std::time::{Duration, Instant}; diff --git a/src/interceptor/report/receiver_report.rs b/src/interceptors/report/receiver_report.rs similarity index 94% rename from src/interceptor/report/receiver_report.rs rename to src/interceptors/report/receiver_report.rs index b74ef11..197802e 100644 --- a/src/interceptor/report/receiver_report.rs +++ b/src/interceptors/report/receiver_report.rs @@ -1,6 +1,6 @@ -use crate::interceptor::report::receiver_stream::ReceiverStream; -use crate::interceptor::report::ReportBuilder; -use crate::interceptor::{Interceptor, InterceptorEvent}; +use crate::interceptors::report::receiver_stream::ReceiverStream; +use crate::interceptors::report::ReportBuilder; +use crate::interceptors::{Interceptor, InterceptorEvent}; use crate::messages::{MessageEvent, RTPMessageEvent, TaggedMessageEvent}; use crate::types::FourTuple; use retty::transport::TransportContext; diff --git a/src/interceptor/report/receiver_stream.rs b/src/interceptors/report/receiver_stream.rs similarity index 100% rename from src/interceptor/report/receiver_stream.rs rename to src/interceptors/report/receiver_stream.rs diff --git a/src/interceptor/report/sender_report.rs b/src/interceptors/report/sender_report.rs similarity index 95% rename from src/interceptor/report/sender_report.rs rename to src/interceptors/report/sender_report.rs index 7a146d6..237c1bf 100644 --- a/src/interceptor/report/sender_report.rs +++ b/src/interceptors/report/sender_report.rs @@ -1,5 +1,5 @@ -use crate::interceptor::report::ReportBuilder; -use crate::interceptor::{Interceptor, InterceptorEvent}; +use crate::interceptors::report::ReportBuilder; +use crate::interceptors::{Interceptor, InterceptorEvent}; use crate::messages::{MessageEvent, RTPMessageEvent, TaggedMessageEvent}; use rtcp::header::PacketType; diff --git a/src/interceptor/twcc/mod.rs b/src/interceptors/twcc/mod.rs similarity index 100% rename from src/interceptor/twcc/mod.rs rename to src/interceptors/twcc/mod.rs diff --git a/src/lib.rs b/src/lib.rs index f9f48f7..8eb601b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,20 +1,22 @@ #![warn(rust_2018_idioms)] #![allow(dead_code)] +pub(crate) mod configs; pub(crate) mod description; pub(crate) mod endpoint; -pub(crate) mod handler; -pub(crate) mod interceptor; +pub(crate) mod handlers; +pub(crate) mod interceptors; pub(crate) mod messages; pub(crate) mod metrics; pub(crate) mod server; pub(crate) mod session; pub(crate) mod types; +pub use configs::{media_config::MediaConfig, server_config::ServerConfig}; pub use description::RTCSessionDescription; -pub use handler::{ +pub use handlers::{ datachannel::DataChannelHandler, demuxer::DemuxerHandler, dtls::DtlsHandler, exception::ExceptionHandler, gateway::GatewayHandler, interceptor::InterceptorHandler, sctp::SctpHandler, srtp::SrtpHandler, stun::StunHandler, }; -pub use server::{certificate::RTCCertificate, config::ServerConfig, states::ServerStates}; +pub use server::{certificate::RTCCertificate, states::ServerStates}; diff --git a/src/server/mod.rs b/src/server/mod.rs index 4907767..33806a9 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,3 +1,2 @@ pub(crate) mod certificate; -pub(crate) mod config; pub(crate) mod states; diff --git a/src/server/states.rs b/src/server/states.rs index 1244751..e5f18c7 100644 --- a/src/server/states.rs +++ b/src/server/states.rs @@ -1,3 +1,5 @@ +use crate::configs::server_config::ServerConfig; +use crate::configs::session_config::SessionConfig; use crate::description::RTCSessionDescription; use crate::endpoint::{ candidate::{Candidate, ConnectionCredentials}, @@ -5,8 +7,7 @@ use crate::endpoint::{ Endpoint, }; use crate::metrics::Metrics; -use crate::server::config::ServerConfig; -use crate::session::{config::SessionConfig, Session}; +use crate::session::Session; use crate::types::{EndpointId, FourTuple, SessionId, UserName}; use log::{debug, info}; use opentelemetry::metrics::Meter; @@ -22,12 +23,11 @@ use std::time::Instant; pub struct ServerStates { server_config: Arc, local_addr: SocketAddr, - sessions: HashMap, metrics: Metrics, - //TODO: add idle timeout cleanup logic to remove idle endpoint and candidates - candidates: HashMap>, + sessions: HashMap, endpoints: HashMap, + candidates: HashMap>, } impl ServerStates { @@ -48,11 +48,10 @@ impl ServerStates { Ok(Self { server_config, local_addr, - sessions: HashMap::new(), metrics: Metrics::new(meter), - - candidates: HashMap::new(), + sessions: HashMap::new(), endpoints: HashMap::new(), + candidates: HashMap::new(), }) } diff --git a/src/session/mod.rs b/src/session/mod.rs index a19ff6f..569d2ea 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -6,8 +6,7 @@ use shared::error::{Error, Result}; use std::collections::{HashMap, HashSet}; use std::rc::Rc; -pub(crate) mod config; - +use crate::configs::session_config::SessionConfig; use crate::description::{ codecs_from_media_description, get_cname, get_mid_value, get_msid, get_peer_direction, get_rids, get_ssrc_groups, get_ssrcs, populate_sdp, rtp_extensions_from_media_description, @@ -24,7 +23,6 @@ use crate::endpoint::{ transport::Transport, Endpoint, }; -use crate::session::config::SessionConfig; use crate::types::{EndpointId, Mid, SessionId}; pub(crate) struct Session {