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

Pass Candidate Protocol arounds along with Address(es) so that routing to the correct ICE route can be done cleanly. #391

Merged
merged 7 commits into from
Oct 18, 2023
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
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let mut rtc = Rtc::new();

// Add some ICE candidate such as a locally bound UDP port.
let addr = "1.2.3.4:5000".parse().unwrap();
let candidate = Candidate::host(addr).unwrap();
let candidate = Candidate::host(addr, "udp").unwrap();
rtc.add_local_candidate(candidate);

// Accept an incoming offer from the remote peer
Expand All @@ -83,7 +83,7 @@ let mut rtc = Rtc::new();

// Add some ICE candidate such as a locally bound UDP port.
let addr = "1.2.3.4:5000".parse().unwrap();
let candidate = Candidate::host(addr).unwrap();
let candidate = Candidate::host(addr, "udp").unwrap();
rtc.add_local_candidate(candidate);

// Create a `SdpApi`. The change lets us make multiple changes
Expand Down Expand Up @@ -176,6 +176,7 @@ loop {
Input::Receive(
Instant::now(),
Receive {
proto: Protocol::Udp,
source,
destination: socket.local_addr().unwrap(),
contents: buf.as_slice().try_into().unwrap(),
Expand Down Expand Up @@ -220,9 +221,9 @@ let writer = rtc.writer(mid).unwrap();
let pt = writer.payload_params()[0].pt();

// Write the data
let wallclock = todo!(); // Absolute time of the data
let media_time = todo!(); // Media time, in RTP time
let data = todo!(); // Actual data
let wallclock = todo!(); // Absolute time of the data
let media_time = todo!(); // Media time, in RTP time
let data: &[u8] = todo!(); // Actual data
writer.write(pt, wallclock, media_time, data).unwrap();
```

Expand Down Expand Up @@ -486,4 +487,4 @@ when catching a panic.

<a href="https://zulip.com/"><image width="70px" src="https://raw.githubusercontent.com/zulip/zulip/main/static/images/logo/zulip-icon-circle.svg" alt="Zulip logo"></image></a>

License: MIT/Apache-2.0
License: MIT OR Apache-2.0
7 changes: 4 additions & 3 deletions examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use str0m::change::{SdpAnswer, SdpOffer, SdpPendingOffer};
use str0m::channel::{ChannelData, ChannelId};
use str0m::media::MediaKind;
use str0m::media::{Direction, KeyframeRequest, MediaData, Mid, Rid};
use str0m::Event;
use str0m::{net::Receive, Candidate, IceConnectionState, Input, Output, Rtc, RtcError};
use str0m::net::Protocol;
use str0m::{net::Receive, Candidate, Event, IceConnectionState, Input, Output, Rtc, RtcError};

mod util;

Expand Down Expand Up @@ -87,7 +87,7 @@ fn web_request(request: &Request, addr: SocketAddr, tx: SyncSender<Rtc>) -> Resp
.build();

// Add the shared UDP socket as a host candidate
let candidate = Candidate::host(addr).expect("a host candidate");
let candidate = Candidate::host(addr, "udp").expect("a host candidate");
rtc.add_local_candidate(candidate);

// Create an SDP Answer.
Expand Down Expand Up @@ -240,6 +240,7 @@ fn read_socket_input<'a>(socket: &UdpSocket, buf: &'a mut Vec<u8>) -> Option<Inp
return Some(Input::Receive(
Instant::now(),
Receive {
proto: Protocol::Udp,
source,
destination: socket.local_addr().unwrap(),
contents,
Expand Down
7 changes: 4 additions & 3 deletions examples/http-post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use rouille::Server;
use rouille::{Request, Response};

use str0m::change::SdpOffer;
use str0m::net::Protocol;
use str0m::net::Receive;
use str0m::IceConnectionState;
use str0m::{Candidate, Event, Input, Output, Rtc, RtcError};
use str0m::{Candidate, Event, IceConnectionState, Input, Output, Rtc, RtcError};

mod util;

Expand Down Expand Up @@ -62,7 +62,7 @@ fn web_request(request: &Request) -> Response {
// Spin up a UDP socket for the RTC
let socket = UdpSocket::bind(format!("{addr}:0")).expect("binding a random UDP port");
let addr = socket.local_addr().expect("a local socket adddress");
let candidate = Candidate::host(addr).expect("a host candidate");
let candidate = Candidate::host(addr, "udp").expect("a host candidate");
rtc.add_local_candidate(candidate);

// Create an SDP Answer.
Expand Down Expand Up @@ -124,6 +124,7 @@ fn run(mut rtc: Rtc, socket: UdpSocket) -> Result<(), RtcError> {
Input::Receive(
Instant::now(),
Receive {
proto: Protocol::Udp,
source,
destination: socket.local_addr().unwrap(),
contents: buf.as_slice().try_into()?,
Expand Down
Loading
Loading