Skip to content

Commit

Permalink
refactor configs and handlers, interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Mar 8, 2024
1 parent a2a9115 commit 144e45f
Show file tree
Hide file tree
Showing 28 changed files with 33 additions and 34 deletions.
9 changes: 4 additions & 5 deletions src/description/config.rs → src/configs/media_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub(crate) mod media_config;
pub(crate) mod server_config;
pub(crate) mod session_config;
2 changes: 1 addition & 1 deletion src/server/config.rs → src/configs/server_config.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/session/config.rs → src/configs/session_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::server::config::ServerConfig;
use crate::configs::server_config::ServerConfig;
use std::net::SocketAddr;
use std::sync::Arc;

Expand Down
3 changes: 1 addition & 2 deletions src/description/mod.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/description/rtp_codec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::configs::media_config::*;
use crate::description::{
config::*,
fmtp,
rtp_transceiver::{PayloadType, RTCPFeedback},
};
Expand Down
2 changes: 1 addition & 1 deletion src/endpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/handler/interceptor.rs → src/handlers/interceptor.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::interceptor::{Interceptor, InterceptorBuilder};
use crate::interceptors::{Interceptor, InterceptorBuilder};
use std::collections::HashMap;
use std::time::{Duration, Instant};

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
1 change: 0 additions & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub(crate) mod certificate;
pub(crate) mod config;
pub(crate) mod states;
15 changes: 7 additions & 8 deletions src/server/states.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::configs::server_config::ServerConfig;
use crate::configs::session_config::SessionConfig;
use crate::description::RTCSessionDescription;
use crate::endpoint::{
candidate::{Candidate, ConnectionCredentials},
transport::Transport,
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;
Expand All @@ -22,12 +23,11 @@ use std::time::Instant;
pub struct ServerStates {
server_config: Arc<ServerConfig>,
local_addr: SocketAddr,
sessions: HashMap<SessionId, Session>,
metrics: Metrics,

//TODO: add idle timeout cleanup logic to remove idle endpoint and candidates
candidates: HashMap<UserName, Rc<Candidate>>,
sessions: HashMap<SessionId, Session>,
endpoints: HashMap<FourTuple, (SessionId, EndpointId)>,
candidates: HashMap<UserName, Rc<Candidate>>,
}

impl ServerStates {
Expand All @@ -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(),
})
}

Expand Down
4 changes: 1 addition & 3 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 144e45f

Please sign in to comment.