Skip to content
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
32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,28 @@ repository = "https://github.com/webrtc-rs/webrtc"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
util = { package = "webrtc-util", version = "0.4.3" }
sdp = "0.2.3"
mdns = { package = "webrtc-mdns", version = "0.3.5" }
stun = "0.3.5"
turn = "0.4.0"
ice = { package = "webrtc-ice", version = "0.4.1" }
dtls = { package = "webrtc-dtls", version = "0.4.12" }
rtp = "0.4.1"
rtcp = "0.4.1"
srtp = { package = "webrtc-srtp", version = "0.5.0" }
sctp = { package = "webrtc-sctp", version = "0.3.8" }
data = { package = "webrtc-data", version = "0.2.8" }
media = { package = "webrtc-media", version = "0.2.1" }
interceptor = "0.2.3"
util = { package = "webrtc-util", version = "0.5.0" }
sdp = "0.3.0"
mdns = { package = "webrtc-mdns", version = "0.4.0" }
stun = "0.4.0"
turn = "0.5.0"
ice = { package = "webrtc-ice", version = "0.5.0" }
dtls = { package = "webrtc-dtls", version = "0.5.0" }
rtp = "0.5.0"
rtcp = "0.5.0"
srtp = { package = "webrtc-srtp", version = "0.6.0" }
sctp = { package = "webrtc-sctp", version = "0.4.0" }
data = { package = "webrtc-data", version = "0.3.0" }
media = { package = "webrtc-media", version = "0.3.0" }
interceptor = "0.3.0"
tokio = { version = "1.12.0", features = ["full"] }
log = "0.4.14"
async-trait = "0.1.42"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rand = "0.8"
bytes = "1"
thiserror = "1.0.25"
anyhow = "1.0.41"
thiserror = "1.0"
waitgroup = "0.1.2"
regex = "1"
url = "2.2.2"
Expand All @@ -53,6 +52,7 @@ clap = "2"
hyper = { version = "0.14.13", features = ["full"] }
signal = {path = "examples/signal" }
tokio-util = "0.6.8"
anyhow = "1.0"

[profile.dev]
opt-level = 0
Expand Down
2 changes: 1 addition & 1 deletion crates/data
Submodule data updated from 4235cc to 36dec3
2 changes: 1 addition & 1 deletion crates/dtls
Submodule dtls updated from 3c1638 to 4c1602
2 changes: 1 addition & 1 deletion crates/ice
Submodule ice updated from 2e379c to 7ff710
2 changes: 1 addition & 1 deletion crates/interceptor
2 changes: 1 addition & 1 deletion crates/mdns
Submodule mdns updated from 584cb6 to 4a2d7c
2 changes: 1 addition & 1 deletion crates/media
Submodule media updated from 5ccf0a to 3a9b0d
2 changes: 1 addition & 1 deletion crates/rtcp
Submodule rtcp updated from cbc3ef to 4df3b5
2 changes: 1 addition & 1 deletion crates/rtp
Submodule rtp updated from fa3858 to 5a8d8e
2 changes: 1 addition & 1 deletion crates/sctp
Submodule sctp updated from 60ff7b to 16cbb5
2 changes: 1 addition & 1 deletion crates/sdp
Submodule sdp updated from cb9211 to c413ad
2 changes: 1 addition & 1 deletion crates/srtp
Submodule srtp updated from 762308 to 7af52f
2 changes: 1 addition & 1 deletion crates/stun
Submodule stun updated from d6e25e to 04a1b0
2 changes: 1 addition & 1 deletion crates/turn
Submodule turn updated from 986cdd to 6d2dec
12 changes: 6 additions & 6 deletions examples/broadcast/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use tokio::time::Duration;
use webrtc::api::interceptor_registry::register_default_interceptors;
use webrtc::api::media_engine::MediaEngine;
use webrtc::api::APIBuilder;
use webrtc::error::Error;
use webrtc::media::rtp::rtp_codec::RTPCodecType;
use webrtc::media::rtp::rtp_receiver::RTCRtpReceiver;
use webrtc::media::track::track_local::track_local_static_rtp::TrackLocalStaticRTP;
Expand All @@ -18,6 +17,7 @@ use webrtc::peer::configuration::RTCConfiguration;
use webrtc::peer::ice::ice_server::RTCIceServer;
use webrtc::peer::peer_connection_state::RTCPeerConnectionState;
use webrtc::peer::sdp::session_description::RTCSessionDescription;
use webrtc::Error;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -147,7 +147,7 @@ async fn main() -> Result<()> {
result = pc2.write_rtcp(&PictureLossIndication{
sender_ssrc: 0,
media_ssrc,
}).await;
}).await.map_err(Into::into);
}
};
}
Expand All @@ -157,7 +157,7 @@ async fn main() -> Result<()> {
tokio::spawn(async move {
// Create Track that we send video back to browser on
let local_track = Arc::new(TrackLocalStaticRTP::new(
track.codec().await.capability.clone(),
track.codec().await.capability,
"video".to_owned(),
"webrtc-rs".to_owned(),
));
Expand All @@ -166,7 +166,7 @@ async fn main() -> Result<()> {
// Read RTP packets being sent to webrtc-rs
while let Ok((rtp, _)) = track.read_rtp().await {
if let Err(err) = local_track.write_rtp(&rtp).await {
if !Error::ErrClosedPipe.equal(&err) {
if Error::ErrClosedPipe != err {
print!("output track write_rtp got error: {} and break", err);
break;
} else {
Expand All @@ -186,7 +186,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);
Box::pin(async {})
}))
.await;
Expand Down Expand Up @@ -274,7 +274,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);
Box::pin(async {})
}))
.await;
Expand Down
6 changes: 3 additions & 3 deletions examples/data-channels-close/data-channels-close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);
let (done_tx, mut done_rx) = tokio::sync::mpsc::channel::<()>(1);
Expand All @@ -170,7 +170,7 @@ async fn main() -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d2.send_text(message).await;
result = d2.send_text(message).await.map_err(Into::into);

let cnt = close_after2.fetch_sub(1, Ordering::SeqCst);
if cnt <= 0 {
Expand All @@ -187,7 +187,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down
2 changes: 1 addition & 1 deletion examples/data-channels-create/data-channels-create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn main() -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d2.send_text(message).await;
result = d2.send_text(message).await.map_err(Into::into);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async fn write_loop(d: Arc<data::data_channel::DataChannel>) -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d.write(&Bytes::from(message)).await;
result = d.write(&Bytes::from(message)).await.map_err(Into::into);
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions examples/data-channels-detach/data-channels-detach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open.", d_label2, d_id2);

Expand Down Expand Up @@ -235,7 +235,7 @@ async fn write_loop(d: Arc<data::data_channel::DataChannel>) -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d.write(&Bytes::from(message)).await;
result = d.write(&Bytes::from(message)).await.map_err(Into::into);
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions examples/data-channels/data-channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);

Expand All @@ -138,7 +138,7 @@ async fn main() -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d2.send_text(message).await;
result = d2.send_text(message).await.map_err(Into::into);
}
};
}
Expand All @@ -148,7 +148,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down
4 changes: 2 additions & 2 deletions examples/insertable-streams/insertable-streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use tokio::time::Duration;
use webrtc::api::interceptor_registry::register_default_interceptors;
use webrtc::api::media_engine::{MediaEngine, MIME_TYPE_VP8};
use webrtc::api::APIBuilder;
use webrtc::error::Error;
use webrtc::media::rtp::rtp_codec::RTCRtpCodecCapability;
use webrtc::media::track::track_local::track_local_static_sample::TrackLocalStaticSample;
use webrtc::media::track::track_local::TrackLocal;
Expand All @@ -22,6 +21,7 @@ use webrtc::peer::ice::ice_connection_state::RTCIceConnectionState;
use webrtc::peer::ice::ice_server::RTCIceServer;
use webrtc::peer::peer_connection_state::RTCPeerConnectionState;
use webrtc::peer::sdp::session_description::RTCSessionDescription;
use webrtc::Error;

const CIPHER_KEY: u8 = 0xAA;

Expand Down Expand Up @@ -205,7 +205,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
8 changes: 4 additions & 4 deletions examples/offer-answer/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async fn remote_handler(req: Request<Body>) -> Result<Response<Body>, hyper::Err
Ok(resp) => resp,
Err(err) => {
println!("{}", err);
return Err(err.into());
return Err(err);
}
};
//println!("remote_handler Response: {}", resp.status());
Expand Down Expand Up @@ -348,7 +348,7 @@ async fn main() -> Result<()> {
// Register channel opening handling
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);
Box::pin(async move {
Expand All @@ -361,7 +361,7 @@ async fn main() -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d2.send_text(message).await;
result = d2.send_text(message).await.map_err(Into::into);
}
};
}
Expand All @@ -371,7 +371,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async{})
})).await;
})
Expand Down
2 changes: 1 addition & 1 deletion examples/offer-answer/offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async fn main() -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d2.send_text(message).await;
result = d2.send_text(message).await.map_err(Into::into);
}
};
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ortc/ortc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);

Expand All @@ -116,7 +116,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down Expand Up @@ -204,7 +204,7 @@ async fn main() -> Result<()> {
let d_label = d.label().to_owned();
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
}))
.await;
Expand Down Expand Up @@ -244,7 +244,7 @@ async fn handle_on_open(d: Arc<RTCDataChannel>) -> Result<()> {
_ = timeout.as_mut() =>{
let message = math_rand_alpha(15);
println!("Sending '{}'", message);
result = d.send_text(message).await;
result = d.send_text(message).await.map_err(Into::into);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion examples/play-from-disk-h264/play-from-disk-h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use tokio::time::Duration;
use webrtc::api::interceptor_registry::register_default_interceptors;
use webrtc::api::media_engine::{MediaEngine, MIME_TYPE_H264, MIME_TYPE_OPUS};
use webrtc::api::APIBuilder;
use webrtc::error::Error;
use webrtc::media::rtp::rtp_codec::RTCRtpCodecCapability;
use webrtc::media::track::track_local::track_local_static_sample::TrackLocalStaticSample;
use webrtc::media::track::track_local::TrackLocal;
Expand All @@ -23,6 +22,7 @@ use webrtc::peer::ice::ice_connection_state::RTCIceConnectionState;
use webrtc::peer::ice::ice_server::RTCIceServer;
use webrtc::peer::peer_connection_state::RTCPeerConnectionState;
use webrtc::peer::sdp::session_description::RTCSessionDescription;
use webrtc::Error;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use tokio_util::codec::{BytesCodec, FramedRead};
use webrtc::api::interceptor_registry::register_default_interceptors;
use webrtc::api::media_engine::{MediaEngine, MIME_TYPE_VP8};
use webrtc::api::APIBuilder;
use webrtc::error::Error;
use webrtc::media::rtp::rtp_codec::RTCRtpCodecCapability;
use webrtc::media::track::track_local::track_local_static_sample::TrackLocalStaticSample;
use webrtc::media::track::track_local::TrackLocal;
Expand All @@ -27,6 +26,7 @@ use webrtc::peer::ice::ice_server::RTCIceServer;
use webrtc::peer::peer_connection::RTCPeerConnection;
use webrtc::peer::peer_connection_state::RTCPeerConnectionState;
use webrtc::peer::sdp::session_description::RTCSessionDescription;
use webrtc::Error;

#[macro_use]
extern crate lazy_static;
Expand Down Expand Up @@ -323,7 +323,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down Expand Up @@ -383,7 +383,7 @@ async fn write_video_to_track(video_file: String, t: Arc<TrackLocalStaticSample>
Ok((frame, _)) => frame,
Err(err) => {
println!("All video frames parsed and sent: {}", err);
return Err(err);
return Err(err.into());
}
};

Expand Down
Loading