Skip to content

Refactor out use of anyhow #109

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

Merged
merged 4 commits into from
Oct 9, 2021
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/dtls
Submodule dtls updated 71 files
+1 −1 .github/workflows/cargo.yml
+3 −4 Cargo.toml
+3 −3 examples/dial/psk/dial_psk.rs
+2 −2 examples/dial/selfsign/dial_selfsign.rs
+4 −5 examples/dial/verify/dial_verify.rs
+4 −3 examples/hub/Cargo.toml
+4 −3 examples/hub/src/lib.rs
+20 −16 examples/hub/src/utilities.rs
+4 −4 examples/listen/psk/listen_psk.rs
+3 −3 examples/listen/selfsign/listen_selfsign.rs
+5 −6 examples/listen/verify/listen_verify.rs
+1 −1 src/alert/alert_test.rs
+1 −1 src/alert/mod.rs
+1 −2 src/application_data.rs
+1 −2 src/change_cipher_spec/mod.rs
+6 −10 src/cipher_suite/cipher_suite_aes_128_ccm.rs
+6 −10 src/cipher_suite/cipher_suite_aes_128_gcm_sha256.rs
+6 −10 src/cipher_suite/cipher_suite_aes_256_cbc_sha.rs
+6 −10 src/cipher_suite/cipher_suite_tls_psk_with_aes_128_gcm_sha256.rs
+2 −3 src/cipher_suite/mod.rs
+2 −1 src/compression_methods.rs
+5 −6 src/config.rs
+16 −21 src/conn/conn_test.rs
+36 −33 src/conn/mod.rs
+1 −2 src/content.rs
+1 −1 src/crypto/crypto_cbc.rs
+5 −5 src/crypto/crypto_ccm.rs
+3 −3 src/crypto/crypto_gcm.rs
+3 −3 src/crypto/crypto_test.rs
+27 −27 src/crypto/mod.rs
+2 −3 src/curve/named_curve.rs
+73 −4 src/error.rs
+1 −2 src/extension/extension_server_name.rs
+0 −2 src/extension/extension_supported_elliptic_curves.rs
+0 −2 src/extension/extension_supported_point_formats.rs
+0 −2 src/extension/extension_supported_signature_algorithms.rs
+0 −2 src/extension/extension_use_extended_master_secret.rs
+0 −2 src/extension/extension_use_srtp.rs
+1 −2 src/extension/mod.rs
+1 −1 src/extension/renegotiation_info.rs
+8 −8 src/flight/flight0.rs
+4 −4 src/flight/flight1.rs
+5 −5 src/flight/flight2.rs
+11 −11 src/flight/flight3.rs
+11 −11 src/flight/flight4.rs
+9 −9 src/flight/flight5.rs
+2 −2 src/flight/flight6.rs
+3 −2 src/flight/mod.rs
+4 −5 src/fragment_buffer/mod.rs
+3 −4 src/handshake/handshake_cache.rs
+0 −1 src/handshake/handshake_header.rs
+0 −1 src/handshake/handshake_message_certificate.rs
+0 −1 src/handshake/handshake_message_certificate_request.rs
+0 −1 src/handshake/handshake_message_certificate_verify.rs
+1 −2 src/handshake/handshake_message_client_hello.rs
+2 −3 src/handshake/handshake_message_client_key_exchange.rs
+0 −1 src/handshake/handshake_message_finished.rs
+2 −3 src/handshake/handshake_message_hello_verify_request.rs
+0 −1 src/handshake/handshake_message_server_hello.rs
+0 −1 src/handshake/handshake_message_server_hello_done.rs
+7 −8 src/handshake/handshake_message_server_key_exchange.rs
+4 −5 src/handshake/handshake_random.rs
+1 −2 src/handshake/mod.rs
+4 −5 src/handshaker.rs
+3 −1 src/lib.rs
+9 −5 src/listener.rs
+9 −7 src/prf/mod.rs
+3 −4 src/record_layer/mod.rs
+2 −3 src/record_layer/record_layer_header.rs
+4 −5 src/signature_hash_algorithm/mod.rs
+16 −18 src/state.rs
2 changes: 1 addition & 1 deletion crates/rtcp
Submodule rtcp updated 32 files
+1 −1 .github/workflows/cargo.yml
+3 −4 Cargo.toml
+14 −33 src/compound_packet/compound_packet_test.rs
+2 −1 src/compound_packet/mod.rs
+19 −5 src/error.rs
+8 −12 src/goodbye/goodbye_test.rs
+2 −1 src/goodbye/mod.rs
+10 −14 src/header.rs
+3 −1 src/lib.rs
+8 −14 src/packet.rs
+7 −11 src/payload_feedbacks/full_intra_request/full_intra_request_test.rs
+2 −1 src/payload_feedbacks/full_intra_request/mod.rs
+2 −1 src/payload_feedbacks/picture_loss_indication/mod.rs
+7 −11 src/payload_feedbacks/picture_loss_indication/picture_loss_indication_test.rs
+2 −1 src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs
+4 −6 src/payload_feedbacks/receiver_estimated_maximum_bitrate/receiver_estimated_maximum_bitrate_test.rs
+2 −1 src/payload_feedbacks/slice_loss_indication/mod.rs
+7 −11 src/payload_feedbacks/slice_loss_indication/slice_loss_indication_test.rs
+3 −4 src/raw_packet.rs
+2 −1 src/receiver_report/mod.rs
+8 −12 src/receiver_report/receiver_report_test.rs
+2 −3 src/reception_report.rs
+2 −1 src/sender_report/mod.rs
+7 −11 src/sender_report/sender_report_test.rs
+2 −1 src/source_description/mod.rs
+7 −11 src/source_description/source_description_test.rs
+2 −1 src/transport_feedbacks/rapid_resynchronization_request/mod.rs
+7 −11 src/transport_feedbacks/rapid_resynchronization_request/rapid_resynchronization_request_test.rs
+2 −1 src/transport_feedbacks/transport_layer_cc/mod.rs
+2 −3 src/transport_feedbacks/transport_layer_nack/mod.rs
+7 −11 src/transport_feedbacks/transport_layer_nack/transport_layer_nack_test.rs
+3 −4 src/util.rs
2 changes: 1 addition & 1 deletion crates/sctp
Submodule sctp updated 44 files
+1 −1 .github/workflows/cargo.yml
+3 −4 Cargo.toml
+3 −3 examples/ping.rs
+3 −3 examples/pong.rs
+16 −17 src/association/association_internal.rs
+20 −8 src/association/association_internal/association_internal_test.rs
+19 −16 src/association/association_test.rs
+6 −7 src/association/mod.rs
+1 −2 src/chunk/chunk_abort.rs
+1 −2 src/chunk/chunk_cookie_ack.rs
+1 −2 src/chunk/chunk_cookie_echo.rs
+1 −2 src/chunk/chunk_error.rs
+3 −4 src/chunk/chunk_forward_tsn.rs
+4 −5 src/chunk/chunk_header.rs
+3 −4 src/chunk/chunk_heartbeat.rs
+5 −6 src/chunk/chunk_heartbeat_ack.rs
+7 −8 src/chunk/chunk_init.rs
+2 −3 src/chunk/chunk_payload_data.rs
+2 −3 src/chunk/chunk_reconfig.rs
+3 −4 src/chunk/chunk_selective_ack.rs
+2 −3 src/chunk/chunk_shutdown.rs
+1 −2 src/chunk/chunk_shutdown_ack.rs
+1 −2 src/chunk/chunk_shutdown_complete.rs
+1 −2 src/chunk/mod.rs
+4 −8 src/error.rs
+3 −4 src/error_cause.rs
+3 −1 src/lib.rs
+9 −10 src/packet.rs
+3 −4 src/param/mod.rs
+1 −2 src/param/param_chunk_list.rs
+0 −1 src/param/param_forward_tsn_supported.rs
+2 −3 src/param/param_header.rs
+0 −1 src/param/param_heartbeat_info.rs
+1 −2 src/param/param_outgoing_reset_request.rs
+0 −1 src/param/param_random.rs
+1 −2 src/param/param_reconfig_response.rs
+1 −2 src/param/param_requested_hmac_algorithm.rs
+0 −1 src/param/param_state_cookie.rs
+0 −1 src/param/param_supported_extensions.rs
+3 −6 src/queue/queue_test.rs
+6 −6 src/queue/reassembly_queue.rs
+8 −8 src/stream/mod.rs
+9 −2 src/timer/timer_test.rs
+4 −3 src/util.rs
2 changes: 1 addition & 1 deletion crates/turn
Submodule turn updated 49 files
+4 −5 Cargo.toml
+4 −4 examples/turn_client_udp.rs
+11 −7 examples/turn_server_udp.rs
+2 −3 src/allocation/allocation_manager.rs
+4 −4 src/allocation/allocation_manager/allocation_manager_test.rs
+1 −0 src/allocation/channel_bind/channel_bind_test.rs
+1 −1 src/allocation/five_tuple/five_tuple_test.rs
+3 −4 src/allocation/mod.rs
+5 −3 src/auth/mod.rs
+2 −2 src/client/binding/binding_test.rs
+11 −13 src/client/mod.rs
+1 −2 src/client/periodic_timer/periodic_timer_test.rs
+38 −36 src/client/relay_conn.rs
+4 −3 src/client/relay_conn/relay_conn_test.rs
+2 −2 src/client/transaction.rs
+39 −6 src/error.rs
+3 −1 src/lib.rs
+1 −1 src/proto/addr/addr_test.rs
+3 −5 src/proto/chandata.rs
+4 −6 src/proto/chandata/chandata_test.rs
+2 −3 src/proto/channum.rs
+6 −5 src/proto/channum/channnum_test.rs
+2 −3 src/proto/data.rs
+4 −3 src/proto/data/data_test.rs
+2 −3 src/proto/dontfrag.rs
+2 −2 src/proto/dontfrag/dontfrag_test.rs
+2 −3 src/proto/evenport.rs
+6 −5 src/proto/evenport/evenport_test.rs
+2 −3 src/proto/lifetime.rs
+5 −4 src/proto/lifetime/lifetime_test.rs
+2 −3 src/proto/peeraddr.rs
+1 −1 src/proto/peeraddr/peeraddr_test.rs
+2 −4 src/proto/proto_test.rs
+2 −3 src/proto/relayaddr.rs
+1 −1 src/proto/relayaddr/relayaddr_test.rs
+3 −6 src/proto/reqfamily.rs
+5 −4 src/proto/reqfamily/reqfamily_test.rs
+2 −3 src/proto/reqtrans.rs
+5 −4 src/proto/reqtrans/reqtrans_test.rs
+2 −3 src/proto/rsrvtoken.rs
+4 −3 src/proto/rsrvtoken/rsrvtoken_test.rs
+2 −1 src/relay/mod.rs
+1 −2 src/relay/relay_none.rs
+5 −6 src/relay/relay_range.rs
+1 −2 src/relay/relay_static.rs
+1 −2 src/server/config.rs
+1 −1 src/server/mod.rs
+29 −27 src/server/request.rs
+1 −1 src/server/server_test.rs
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