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

Refactor crypto feature flags #594

Merged
merged 1 commit into from
Dec 27, 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.cargo.features": "all"
}
1 change: 1 addition & 0 deletions src/_internal_test_exports/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub fn rtp_packet(data: &[u8]) -> Option<()> {
let mut session = Session::new(&config);
session.set_keying_material(
KeyingMaterial::new(rng.slice(16)?.to_vec()),
&crate::crypto::SrtpCrypto::new_openssl(),
SrtpProfile::PassThrough,
rng.bool()?,
);
Expand Down
8 changes: 6 additions & 2 deletions src/bwe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@ impl<'a> Bwe<'a> {
/// Staring at the lower layer, call:
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::{Rtc, bwe::Bitrate};
/// let mut rtc = Rtc::new();
///
/// rtc.bwe().set_current_bitrate(Bitrate::kbps(250));
/// ````
/// # }
/// ```
///
/// When a new estimate is made available that indicates a switch to the medium layer is
/// possible, make the switch and then update the configuration:
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::{Rtc, bwe::Bitrate};
/// let mut rtc = Rtc::new();
///
/// rtc.bwe().set_current_bitrate(Bitrate::kbps(750));
/// ````
/// # }
/// ```
///
/// ## Accuracy
///
Expand Down
3 changes: 0 additions & 3 deletions src/change/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ pub use sdp::{SdpAnswer, SdpApi, SdpOffer, SdpPendingOffer};

mod direct;
pub use direct::DirectApi;

pub use crate::crypto::Fingerprint;
pub use crate::dtls::DtlsCert;
16 changes: 16 additions & 0 deletions src/change/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl<'a> SdpApi<'a> {
/// If changes have been made, nothing happens until we call [`SdpApi::apply()`].
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::{Rtc, media::MediaKind, media::Direction};
/// let mut rtc = Rtc::new();
///
Expand All @@ -201,6 +202,7 @@ impl<'a> SdpApi<'a> {
///
/// let mid = changes.add_media(MediaKind::Audio, Direction::SendRecv, None, None);
/// assert!(changes.has_changes());
/// # }
/// ```
pub fn has_changes(&self) -> bool {
!self.changes.0.is_empty()
Expand All @@ -218,12 +220,14 @@ impl<'a> SdpApi<'a> {
/// CNAME in the RTP SDES.
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::{Rtc, media::MediaKind, media::Direction};
/// let mut rtc = Rtc::new();
///
/// let mut changes = rtc.sdp_api();
///
/// let mid = changes.add_media(MediaKind::Audio, Direction::SendRecv, None, None);
/// # }
/// ```
pub fn add_media(
&mut self,
Expand Down Expand Up @@ -322,12 +326,14 @@ impl<'a> SdpApi<'a> {
/// useful when multiple channels are in use at the same time.
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::Rtc;
/// let mut rtc = Rtc::new();
///
/// let mut changes = rtc.sdp_api();
///
/// let cid = changes.add_channel("my special channel".to_string());
/// # }
/// ```
pub fn add_channel(&mut self, label: String) -> ChannelId {
self.add_channel_with_config(ChannelConfig {
Expand All @@ -341,6 +347,7 @@ impl<'a> SdpApi<'a> {
/// Refer to `add_channel` for more details.
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::{channel::{ChannelConfig, Reliability}, Rtc};
/// let mut rtc = Rtc::new();
///
Expand All @@ -352,6 +359,7 @@ impl<'a> SdpApi<'a> {
/// ordered: false,
/// ..Default::default()
/// });
/// # }
/// ```
pub fn add_channel_with_config(&mut self, config: ChannelConfig) -> ChannelId {
let has_media = self.rtc.session.app().is_some();
Expand Down Expand Up @@ -405,11 +413,13 @@ impl<'a> SdpApi<'a> {
/// the current [`SdpPendingOffer`].
///
/// ```
/// # #[cfg(feature = "openssl")] {
/// # use str0m::Rtc;
/// let mut rtc = Rtc::new();
///
/// let changes = rtc.sdp_api();
/// assert!(changes.apply().is_none());
/// # }
/// ```
pub fn apply(self) -> Option<(SdpOffer, SdpPendingOffer)> {
if self.changes.is_empty() {
Expand Down Expand Up @@ -1558,6 +1568,8 @@ mod test {

#[test]
fn test_out_of_order_error() {
crate::init_crypto_default();

let mut rtc1 = Rtc::new();
let mut rtc2 = Rtc::new();

Expand All @@ -1580,6 +1592,8 @@ mod test {

#[test]
fn sdp_api_merge_works() {
crate::init_crypto_default();

let mut rtc = Rtc::new();
let mut changes = rtc.sdp_api();
changes.add_media(MediaKind::Audio, Direction::SendOnly, None, None);
Expand All @@ -1596,6 +1610,8 @@ mod test {

#[test]
fn test_rtp_payload_priority() {
crate::init_crypto_default();

let mut rtc1 = Rtc::builder()
.clear_codecs()
.enable_h264(true)
Expand Down
Loading
Loading