Skip to content

Commit

Permalink
Doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Feb 5, 2024
1 parent 18f56eb commit 9c1cb76
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Active connections means we are making the inital OFFER and waiting for a
remote ANSWER to start the connection.

```rust
#
// Instantiate a new Rtc instance.
let mut rtc = Rtc::new();

Expand Down Expand Up @@ -112,7 +111,6 @@ Driving the state of the `Rtc` forward is a run loop that, regardless of sync or
looks like this.

```rust
#
// Buffer for reading incoming UDP packets.
let mut buf = vec![0; 2000];

Expand Down Expand Up @@ -210,7 +208,6 @@ are negotiated with the remote side. Each codec corresponds to a
to use when sending.

```rust
#
// Obtain mid from Event::MediaAdded
let mid: Mid = todo!();

Expand Down Expand Up @@ -328,9 +325,9 @@ forward by different kinds of input.
Str0m defaults to the "sample level" which treats the RTP as an internal detail. The user
will thus mainly interact with:

1. [`Event::MediaData`] to receive full "samples" (audio frames or video frames).
2. [`Writer::write`][crate::media::Writer::write] to write full samples.
3. [`Writer::request_keyframe`][crate::media::Writer::request_keyframe] to request keyframes.
1. [`Event::MediaData`][evmed] to receive full "samples" (audio frames or video frames).
2. [`Writer::write`][writer] to write full samples.
3. [`Writer::request_keyframe`][reqkey] to request keyframes.

#### Sample level

Expand All @@ -344,18 +341,13 @@ Samples are not suitable to use directly in UDP (RTP) packets - for
one they are too big. Samples are therefore further chunked up by
codec specific payloaders into RTP packets.

#### RTP level
#### RTP mode

Str0m also provides an RTP level API. This would be similar to many other
RTP libraries where the RTP packets themselves are the the API surface
towards the user (when building an SFU one would often talk about "forwarding
RTP packets", while with str0m we can also "forward samples").

#### RTP mode

str0m has a lower level API which let's the user write/receive RTP
packets directly. Using this API requires a deeper knowledge of
RTP and WebRTC.
RTP packets", while with str0m we can also "forward samples"). Using
this API requires a deeper knowledge of RTP and WebRTC.

To enable RTP mode

Expand All @@ -369,10 +361,10 @@ let rtc = Rtc::builder()

RTP mode gives us some new API points.

1. [`Event::RtpPacket`] emitted for every incoming RTP packet. Empty packets for bandwidth
1. [`Event::RtpPacket`][rtppak] emitted for every incoming RTP packet. Empty packets for bandwidth
estimation are silently discarded.
2. [`StreamTx::write_rtp`][crate::rtp::StreamTx::write_rtp] to write outgoing RTP packets.
3. [`StreamRx::request_keyframe`][crate::rtp::StreamRx::request_keyframe] to request keyframes from remote.
2. [`StreamTx::write_rtp`][wrtrtp] to write outgoing RTP packets.
3. [`StreamRx::request_keyframe`][reqkey2] to request keyframes from remote.

### NIC enumeration and TURN (and STUN)

Expand Down Expand Up @@ -558,6 +550,12 @@ Yes use the direct API!
[intg]: https://github.com/algesten/str0m/blob/main/tests/unidirectional.rs#L12
[ff]: https://en.wikipedia.org/wiki/Fail-fast
[catch]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
[evmed]: https://docs.rs/str0m/*/str0m/enum.Event.html#variant.MediaData
[writer]: https://docs.rs/str0m/*/str0m/media/struct.Writer.html#method.write
[reqkey]: https://docs.rs/str0m/*/str0m/media/struct.Writer.html#method.request_keyframe
[rtppak]: https://docs.rs/str0m/*/str0m/enum.Event.html#variant.RtpPacket
[wrtrtp]: https://docs.rs/str0m/*/str0m/rtp/struct.StreamTx.html#method.write_rtp
[reqkey2]: https://docs.rs/str0m/*/str0m/rtp/struct.StreamRx.html#method.request_keyframe

---

Expand Down
32 changes: 15 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
//! ```no_run
//! # use str0m::{Rtc, Candidate};
//! # use str0m::media::{MediaKind, Direction};
//! #
//! // Instantiate a new Rtc instance.
//! let mut rtc = Rtc::new();
//!
Expand Down Expand Up @@ -119,7 +118,6 @@
//! # use std::net::UdpSocket;
//! # use std::time::Instant;
//! # let rtc = Rtc::new();
//! #
//! // Buffer for reading incoming UDP packets.
//! let mut buf = vec![0; 2000];
//!
Expand Down Expand Up @@ -220,7 +218,6 @@
//! # use str0m::Rtc;
//! # use str0m::media::Mid;
//! # let rtc: Rtc = todo!();
//! #
//! // Obtain mid from Event::MediaAdded
//! let mid: Mid = todo!();
//!
Expand Down Expand Up @@ -338,9 +335,9 @@
//! Str0m defaults to the "sample level" which treats the RTP as an internal detail. The user
//! will thus mainly interact with:
//!
//! 1. [`Event::MediaData`] to receive full "samples" (audio frames or video frames).
//! 2. [`Writer::write`][crate::media::Writer::write] to write full samples.
//! 3. [`Writer::request_keyframe`][crate::media::Writer::request_keyframe] to request keyframes.
//! 1. [`Event::MediaData`][evmed] to receive full "samples" (audio frames or video frames).
//! 2. [`Writer::write`][writer] to write full samples.
//! 3. [`Writer::request_keyframe`][reqkey] to request keyframes.
//!
//! ### Sample level
//!
Expand All @@ -354,18 +351,13 @@
//! one they are too big. Samples are therefore further chunked up by
//! codec specific payloaders into RTP packets.
//!
//! ### RTP level
//! ### RTP mode
//!
//! Str0m also provides an RTP level API. This would be similar to many other
//! RTP libraries where the RTP packets themselves are the the API surface
//! towards the user (when building an SFU one would often talk about "forwarding
//! RTP packets", while with str0m we can also "forward samples").
//!
//! ### RTP mode
//!
//! str0m has a lower level API which let's the user write/receive RTP
//! packets directly. Using this API requires a deeper knowledge of
//! RTP and WebRTC.
//! RTP packets", while with str0m we can also "forward samples"). Using
//! this API requires a deeper knowledge of RTP and WebRTC.
//!
//! To enable RTP mode
//!
Expand All @@ -380,10 +372,10 @@
//!
//! RTP mode gives us some new API points.
//!
//! 1. [`Event::RtpPacket`] emitted for every incoming RTP packet. Empty packets for bandwidth
//! 1. [`Event::RtpPacket`][rtppak] emitted for every incoming RTP packet. Empty packets for bandwidth
//! estimation are silently discarded.
//! 2. [`StreamTx::write_rtp`][crate::rtp::StreamTx::write_rtp] to write outgoing RTP packets.
//! 3. [`StreamRx::request_keyframe`][crate::rtp::StreamRx::request_keyframe] to request keyframes from remote.
//! 2. [`StreamTx::write_rtp`][wrtrtp] to write outgoing RTP packets.
//! 3. [`StreamRx::request_keyframe`][reqkey2] to request keyframes from remote.
//!
//! ## NIC enumeration and TURN (and STUN)
//!
Expand Down Expand Up @@ -569,6 +561,12 @@
//! [intg]: https://github.com/algesten/str0m/blob/main/tests/unidirectional.rs#L12
//! [ff]: https://en.wikipedia.org/wiki/Fail-fast
//! [catch]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
//! [evmed]: https://docs.rs/str0m/*/str0m/enum.Event.html#variant.MediaData
//! [writer]: https://docs.rs/str0m/*/str0m/media/struct.Writer.html#method.write
//! [reqkey]: https://docs.rs/str0m/*/str0m/media/struct.Writer.html#method.request_keyframe
//! [rtppak]: https://docs.rs/str0m/*/str0m/enum.Event.html#variant.RtpPacket
//! [wrtrtp]: https://docs.rs/str0m/*/str0m/rtp/struct.StreamTx.html#method.write_rtp
//! [reqkey2]: https://docs.rs/str0m/*/str0m/rtp/struct.StreamRx.html#method.request_keyframe

#![forbid(unsafe_code)]
#![allow(clippy::new_without_default)]
Expand Down

0 comments on commit 9c1cb76

Please sign in to comment.