-
Notifications
You must be signed in to change notification settings - Fork 78
[WIP] SNAP support for direct API #811
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,8 @@ _internal_test_exports = [] | |
| [dependencies] | ||
| tracing = "0.1.37" | ||
| fastrand = "2.0.1" | ||
| sctp-proto = "0.6.0" | ||
| #sctp-proto = "0.7.0" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update this once sctp-change is in |
||
| sctp-proto = { git = "https://github.com/xnorpx/sctp-proto", rev = "97b5a07aa42b9d1678c38fb3e54f068cca4a847f" } | ||
| combine = "4.6.6" | ||
| subtle = "2.0.0" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ use crate::crypto::Fingerprint; | |
| use crate::media::{Media, MediaKind}; | ||
| use crate::rtp_::MidRid; | ||
| use crate::rtp_::{Mid, Rid, Ssrc}; | ||
| use crate::sctp::ChannelConfig; | ||
| use crate::sctp::{ChannelConfig, SctpConfig}; | ||
| use crate::streams::{StreamRx, StreamTx, DEFAULT_RTX_CACHE_DURATION, DEFAULT_RTX_RATIO_CAP}; | ||
| use crate::IceCreds; | ||
| use crate::Rtc; | ||
|
|
@@ -96,6 +96,46 @@ impl<'a> DirectApi<'a> { | |
| self.rtc.init_dtls(active) | ||
| } | ||
|
|
||
| /// Set the SCTP configuration. | ||
| /// | ||
| /// This must be called before [`Self::start_sctp()`] to take effect. | ||
| /// Use this when you have out-of-band negotiated SCTP parameters, | ||
| /// such as the remote INIT chunk. | ||
| /// | ||
| /// # Example | ||
| /// ```ignore | ||
| /// use str0m::channel::SctpConfig; | ||
| /// | ||
| /// let sctp_config = SctpConfig::new() | ||
| /// .with_remote_chunk_init(remote_init_bytes); | ||
| /// rtc.direct_api().set_sctp_config(sctp_config); | ||
| /// rtc.direct_api().start_sctp(false); // server with out-of-band signaling | ||
| /// ``` | ||
| pub fn set_sctp_config(&mut self, config: SctpConfig) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe return error if we already have a config? |
||
| self.rtc.sctp.set_config(config); | ||
| } | ||
|
|
||
| /// Get a mutable reference to the SCTP configuration. | ||
| /// | ||
| /// Use this to modify the config, for example to set the remote INIT chunk | ||
| /// for out-of-band signaling. | ||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Panics if SCTP has already been initialized via `start_sctp()`. | ||
| /// | ||
| /// # Example | ||
| /// ```ignore | ||
| /// // Get local INIT chunk to send via signaling | ||
| /// let local_init = rtc.direct_api().sctp_config().local_init_chunk(); | ||
| /// // ... send local_init via signaling, receive remote_init ... | ||
| /// rtc.direct_api().sctp_config().set_remote_chunk_init(remote_init); | ||
| /// rtc.direct_api().start_sctp(false); // skips SCTP handshake | ||
| /// ``` | ||
| pub fn sctp_config(&mut self) -> &mut SctpConfig { | ||
| self.rtc.sctp.sctp_config() | ||
| } | ||
|
|
||
| /// Start the SCTP over DTLS. | ||
| pub fn start_sctp(&mut self, client: bool) { | ||
| self.rtc.init_sctp(client) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert once sctp changes is in