From d64c7e5e08dd1f6de654794fd5996b76def3489e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Mon, 3 Oct 2022 15:59:43 +0200 Subject: [PATCH] rustfmt & signal_client improvememts - handle ping message - recv now only returns on SignalResponse --- .gitignore | 2 +- Cargo.lock | 4 +- Cargo.toml | 3 + crates/livekit-core/Cargo.toml | 2 +- crates/livekit-core/src/lk_runtime.rs | 1 + crates/livekit-core/src/local_participant.rs | 2 - crates/livekit-core/src/pc_transport.rs | 17 +- crates/livekit-core/src/room.rs | 18 +- crates/livekit-core/src/rtc_engine.rs | 28 +- crates/livekit-core/src/signal_client.rs | 198 +-- .../libwebrtc-sys/include/livekit/jsep.h | 15 +- .../include/livekit/peer_connection.h | 3 +- .../include/livekit/peer_connection_factory.h | 3 +- .../libwebrtc-sys/src/data_channel.cpp | 3 +- .../libwebrtc-sys/src/data_channel.rs | 2 +- .../livekit-webrtc/libwebrtc-sys/src/jsep.rs | 4 +- .../libwebrtc-sys/src/peer_connection.cpp | 3 +- .../libwebrtc-sys/src/peer_connection.rs | 9 +- .../src/peer_connection_factory.cpp | 3 +- .../src/peer_connection_factory.rs | 8 +- .../libwebrtc-sys/src/rtc_error.rs | 3 +- .../libwebrtc-sys/src/rtp_receiver.rs | 2 - .../libwebrtc-sys/src/rtp_transceiver.rs | 2 - .../libwebrtc-sys/src/webrtc.cpp | 2 +- .../libwebrtc-sys/src/webrtc.rs | 3 +- crates/livekit-webrtc/src/data_channel.rs | 9 +- crates/livekit-webrtc/src/jsep.rs | 9 +- crates/livekit-webrtc/src/peer_connection.rs | 15 +- crates/livekit-webrtc/src/rtc_error.rs | 1 + crates/livekit-webrtc/src/webrtc.rs | 2 +- examples/Cargo.lock | 1347 +++++++++++++++++ examples/Cargo.toml | 3 + examples/simple_room/Cargo.toml | 10 + examples/simple_room/src/main.rs | 19 + src/lib.rs | 3 +- 35 files changed, 1584 insertions(+), 174 deletions(-) create mode 100644 examples/Cargo.lock create mode 100644 examples/Cargo.toml create mode 100644 examples/simple_room/Cargo.toml create mode 100644 examples/simple_room/src/main.rs diff --git a/.gitignore b/.gitignore index 8d2cb99..0f45382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -/target +target /.idea /libwebrtc \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 050b261..ad4685b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,6 +495,9 @@ dependencies = [ [[package]] name = "livekit" version = "0.1.0" +dependencies = [ + "livekit-core", +] [[package]] name = "livekit-core" @@ -1063,7 +1066,6 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "tracing", "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 5c8a562..a705033 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,6 @@ members = [ "crates/livekit-webrtc", "crates/livekit-webrtc/libwebrtc-sys" ] + +[dependencies] +livekit-core = { path = "crates/livekit-core" } \ No newline at end of file diff --git a/crates/livekit-core/Cargo.toml b/crates/livekit-core/Cargo.toml index 4483e7d..faf009c 100644 --- a/crates/livekit-core/Cargo.toml +++ b/crates/livekit-core/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" serde = { version = "1", features = ["derive"] } serde_json = "1.0" tokio-tungstenite = { version = "0.17.2", features = ["native-tls"] } -tokio = { version = "1", features = ["full", "tracing"] } +tokio = { version = "1", features = ["full"] } futures = "0.3" url = "2.2.2" futures-util = "0.3.23" diff --git a/crates/livekit-core/src/lk_runtime.rs b/crates/livekit-core/src/lk_runtime.rs index 8858598..ea349ef 100644 --- a/crates/livekit-core/src/lk_runtime.rs +++ b/crates/livekit-core/src/lk_runtime.rs @@ -1,4 +1,5 @@ use std::fmt::{Debug, Formatter}; + use tracing::{event, Level}; use livekit_webrtc::peer_connection_factory::PeerConnectionFactory; diff --git a/crates/livekit-core/src/local_participant.rs b/crates/livekit-core/src/local_participant.rs index 248b2d0..8654368 100644 --- a/crates/livekit-core/src/local_participant.rs +++ b/crates/livekit-core/src/local_participant.rs @@ -43,5 +43,3 @@ impl LocalParticipant { self.engine.lock().await.publish_data(&data, kind).await.map_err(Into::into) } } - - diff --git a/crates/livekit-core/src/pc_transport.rs b/crates/livekit-core/src/pc_transport.rs index 0c65e3f..8d1724d 100644 --- a/crates/livekit-core/src/pc_transport.rs +++ b/crates/livekit-core/src/pc_transport.rs @@ -1,14 +1,17 @@ +use std::fmt::{Debug, Formatter}; use std::future::Future; use std::pin::Pin; use std::time::Duration; -use tracing::{Level, event}; + +use tracing::{event, Level}; + use livekit_webrtc::jsep::{IceCandidate, SessionDescription}; use livekit_webrtc::peer_connection::{ IceConnectionState, PeerConnection, RTCOfferAnswerOptions, SignalingState, }; use livekit_webrtc::rtc_error::RTCError; -const NEGOTIATION_FREQUENCY: Duration = Duration::from_millis(150); // TODO(theomonnom) +const NEGOTIATION_FREQUENCY: Duration = Duration::from_millis(150); pub type OnOfferHandler = Box Pin + Send + 'static>>) + Send + Sync>; @@ -20,6 +23,12 @@ pub struct PCTransport { renegotiate: bool, } +impl Debug for PCTransport { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + f.write_str("PCTransport") + } +} + impl PCTransport { pub fn new(peer_connection: PeerConnection) -> Self { Self { @@ -45,6 +54,7 @@ impl PCTransport { self.on_offer_handler = Some(handler); } + #[tracing::instrument] pub async fn add_ice_candidate(&mut self, ice_candidate: IceCandidate) -> Result<(), RTCError> { if self.peer_connection.remote_description().is_none() { self.pending_candidates.push(ice_candidate); @@ -57,6 +67,7 @@ impl PCTransport { Ok(()) } + #[tracing::instrument] pub async fn set_remote_description( &mut self, remote_description: SessionDescription, @@ -79,12 +90,14 @@ impl PCTransport { Ok(()) } + #[tracing::instrument] pub async fn negotiate(&mut self) -> Result<(), RTCError> { // TODO(theomonnom) Debounce here with NEGOTIATION_FREQUENCY self.create_and_send_offer(RTCOfferAnswerOptions::default()) .await } + #[tracing::instrument] async fn create_and_send_offer( &mut self, options: RTCOfferAnswerOptions, diff --git a/crates/livekit-core/src/room.rs b/crates/livekit-core/src/room.rs index e061a91..b6c7309 100644 --- a/crates/livekit-core/src/room.rs +++ b/crates/livekit-core/src/room.rs @@ -1,12 +1,9 @@ use std::sync::Arc; -use std::time::Duration; use thiserror::Error; use tokio::sync::Mutex; -use tokio::time::sleep; use crate::local_participant::LocalParticipant; -use crate::proto::data_packet; use crate::rtc_engine; use crate::rtc_engine::{EngineError, RTCEngine}; @@ -23,12 +20,11 @@ pub struct Room { engine: Arc>, } -#[tracing::instrument] +#[tracing::instrument(skip(url, token))] pub async fn connect(url: &str, token: &str) -> Result { let engine = rtc_engine::connect(url, token).await?; engine.on_data(Box::new(|packet| { - Box::pin(async move {}) })).await; @@ -58,15 +54,3 @@ impl Room { &self.name } } - - -// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NjgxMzc0NDgsImlzcyI6IkFQSXpLYkFTaUNWYWtnSiIsIm5hbWUiOiJ3ZWIiLCJuYmYiOjE2NjQ1Mzc0NDgsInN1YiI6IndlYiIsInZpZGVvIjp7InJvb21DcmVhdGUiOnRydWUsInJvb21Kb2luIjp0cnVlfX0.6VMDdXJYrW3KWrEzxx4hzbmMQnjQIRILQ48Qrbx5j44 -#[tokio::test] -async fn test_test() { - // console_subscriber::init(); - - let mut room = connect("ws://localhost:7880", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzEyMzk4NjAsImlzcyI6IkFQSXpLYkFTaUNWYWtnSiIsIm5hbWUiOiJ0ZXN0IiwibmJmIjoxNjY0MDM5ODYwLCJzdWIiOiJ0ZXN0IiwidmlkZW8iOnsicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZX19.0Bee2jI2cSZveAbZ8MLc-ADoMYQ4l8IRxcAxpXAS6a8").await.unwrap(); - room.local_participant().publish_data(b"This is a test", data_packet::Kind::Reliable).await.unwrap(); - - sleep(Duration::from_secs(60)).await; -} diff --git a/crates/livekit-core/src/rtc_engine.rs b/crates/livekit-core/src/rtc_engine.rs index 76de28f..dfc1054 100644 --- a/crates/livekit-core/src/rtc_engine.rs +++ b/crates/livekit-core/src/rtc_engine.rs @@ -1,8 +1,8 @@ use std::fmt::{Debug, Formatter}; use std::future::Future; use std::pin::Pin; -use std::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use std::sync::{Arc, Weak}; +use std::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use std::time::Duration; use lazy_static::lazy_static; @@ -23,15 +23,15 @@ use livekit_webrtc::peer_connection_factory::{ }; use livekit_webrtc::rtc_error::RTCError; +use crate::{proto, signal_client}; use crate::lk_runtime::LKRuntime; use crate::pc_transport::PCTransport; -use crate::proto::data_packet::Value; use crate::proto::{ - data_packet, signal_request, signal_response, DataPacket, JoinResponse, SignalTarget, + data_packet, DataPacket, JoinResponse, signal_request, signal_response, SignalTarget, TrickleRequest, UserPacket, }; +use crate::proto::data_packet::Value; use crate::signal_client::{SignalClient, SignalError}; -use crate::{proto, signal_client}; const LOSSY_DC_LABEL: &str = "_lossy"; const RELIABLE_DC_LABEL: &str = "_reliable"; @@ -107,7 +107,7 @@ pub enum EngineMessage { } pub type OnDataHandler = - Box Pin + Send + 'static>>) + Send + Sync>; +Box Pin + Send + 'static>>) + Send + Sync>; struct EngineInternal { publisher_pc: Arc>, @@ -142,7 +142,7 @@ pub struct RTCEngine { lk_runtime: Arc, // Keep a reference while we're using the RTCEngine } -#[tracing::instrument] +#[tracing::instrument(skip(url, token))] pub async fn connect(url: &str, token: &str) -> Result { // Acquire an existing/a new LKRuntime let mut lk_runtime_ref = LK_RUNTIME.lock().await; @@ -214,11 +214,11 @@ impl RTCEngine { *self.internal.on_data_handler.lock().await = Some(f); } - fn data_channel(&self, kind: data_packet::Kind) -> &Arc> { + fn data_channel(&self, kind: data_packet::Kind) -> Arc> { if kind == data_packet::Kind::Reliable { - &self.internal.reliable_dc + self.internal.reliable_dc.clone() } else { - &self.internal.lossy_dc + self.internal.lossy_dc.clone() } } @@ -236,7 +236,7 @@ impl RTCEngine { let mut publisher = publisher.lock().await; if !publisher.is_connected() && publisher.peer_connection().ice_connection_state() - != IceConnectionState::IceConnectionChecking + != IceConnectionState::IceConnectionChecking { tokio::spawn({ let rtc_internal = self.internal.clone(); @@ -265,7 +265,7 @@ impl RTCEngine { interval.tick().await; } }) - .await; + .await; if res.is_err() { let err = @@ -394,7 +394,7 @@ impl RTCEngine { let _ = signal_client.send(signal_request::Message::Trickle( TrickleRequest { candidate_init: json, - target: target as i32 + target: target as i32, }, )).await; }); @@ -469,7 +469,7 @@ impl RTCEngine { data: user, kind: data_packet::Kind::from_i32(data.kind).unwrap(), }) - .await; + .await; } } Value::Speaker(_) => { @@ -502,7 +502,7 @@ impl RTCEngine { } } None => { - // TODO{theomonnom) Trigger reconnect + // TODO(theomonnom) Trigger reconnect } } }, diff --git a/crates/livekit-core/src/signal_client.rs b/crates/livekit-core/src/signal_client.rs index c86ed60..ddd23e7 100644 --- a/crates/livekit-core/src/signal_client.rs +++ b/crates/livekit-core/src/signal_client.rs @@ -1,20 +1,21 @@ -use futures::future::poll_fn; -use futures_util::stream::{SplitSink, SplitStream}; -use futures_util::{SinkExt, StreamExt}; -use prost::Message as ProstMessage; use std::fmt::{Debug, Formatter}; + +use futures::future::poll_fn; +use futures_util::{SinkExt, StreamExt}; +use futures_util::stream::{SplitSink, SplitStream}; +use prost::Message as ProstMessage; use thiserror::Error; use tokio::net::TcpStream; use tokio::sync::{mpsc, oneshot}; use tokio::task::JoinHandle; -use tokio_tungstenite::tungstenite::{ - protocol::frame::{coding::CloseCode, CloseFrame}, - Error as WsError, Message, -}; use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream}; -use tracing::{event, span, Level}; +use tokio_tungstenite::tungstenite::{Error as WsError, Message}; +use tokio_tungstenite::tungstenite::protocol::CloseFrame; +use tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode; +use tracing::{event, Level}; use crate::proto::{signal_request, signal_response, SignalRequest, SignalResponse}; +use crate::signal_client::SendMessage::Pong; pub const PROTOCOL_VERSION: u32 = 8; @@ -32,21 +33,26 @@ type SignalResult = Result; type WebSocket = WebSocketStream>; #[derive(Debug)] -struct RecvMessage { - response_chn: oneshot::Sender>, +enum RecvMessage { + Signal { + response_chn: oneshot::Sender>, + }, } #[derive(Debug)] -struct SendMessage { - signal: signal_request::Message, - response_chn: oneshot::Sender>, +enum SendMessage { + Signal { + signal: signal_request::Message, + response_chn: oneshot::Sender>, + }, + Pong { + ping_data: Vec, + }, } pub struct SignalClient { - read_sender: mpsc::Sender, - write_sender: mpsc::Sender, - write_shutdown_sender: oneshot::Sender<()>, - read_shutdown_sender: oneshot::Sender<()>, + read_tx: mpsc::Sender, + write_tx: mpsc::Sender, read_handle: JoinHandle<()>, write_handle: JoinHandle<()>, } @@ -57,7 +63,7 @@ impl Debug for SignalClient { } } -#[tracing::instrument] +#[tracing::instrument(skip(url, token))] pub async fn connect(url: &str, token: &str) -> SignalResult { let mut lk_url = url::Url::parse(url)?; lk_url.set_path("/rtc"); @@ -74,21 +80,13 @@ pub async fn connect(url: &str, token: &str) -> SignalResult { let (read_tx, read_rx) = mpsc::channel::(8); let (write_tx, write_rx) = mpsc::channel::(8); - let (read_shutdown_tx, read_shutdown_rx) = oneshot::channel(); - let (write_shutdown_tx, write_shutdown_rx) = oneshot::channel(); - let read_handle = tokio::spawn(SignalClient::ws_read(read_rx, ws_reader, read_shutdown_rx)); - let write_handle = tokio::spawn(SignalClient::ws_write( - write_rx, - ws_writer, - write_shutdown_rx, - )); + let read_handle = tokio::spawn(SignalClient::ws_read(read_rx, ws_reader, write_tx.clone())); + let write_handle = tokio::spawn(SignalClient::ws_write(write_rx, ws_writer)); Ok(SignalClient { - read_sender: read_tx, - write_sender: write_tx, - write_shutdown_sender: write_shutdown_tx, - read_shutdown_sender: read_shutdown_tx, + read_tx, + write_tx, read_handle, write_handle, }) @@ -96,99 +94,115 @@ pub async fn connect(url: &str, token: &str) -> SignalResult { impl SignalClient { pub async fn close(self) { - let _ = self.write_shutdown_sender.send(()); - let _ = self.write_handle.await; - let _ = self.read_shutdown_sender.send(()); + drop(self.read_tx); + drop(self.write_tx); + let _ = self.read_handle.await; + let _ = self.write_handle.await; } pub async fn recv(&self) -> Option { let (send, recv) = oneshot::channel(); - let msg = RecvMessage { response_chn: send }; - let _ = self.read_sender.send(msg).await; + let msg = RecvMessage::Signal { response_chn: send }; + let _ = self.read_tx.send(msg).await; recv.await.expect("channel closed") } pub async fn send(&self, signal: signal_request::Message) -> SignalResult<()> { let (send, recv) = oneshot::channel(); - let msg = SendMessage { + let msg = SendMessage::Signal { signal, response_chn: send, }; - let _ = self.write_sender.send(msg).await; + let _ = self.write_tx.send(msg).await; recv.await.expect("channel closed") } - #[tracing::instrument] async fn ws_write( mut write_receiver: mpsc::Receiver, mut ws_writer: SplitSink, - mut shutdown_receiver: oneshot::Receiver<()>, ) { - loop { - tokio::select! { - Some(msg) = write_receiver.recv() => { - event!(Level::TRACE, "sending: {:?}", msg.signal); + while let Some(msg) = write_receiver.recv().await { + match msg { + SendMessage::Signal { + signal, + response_chn, + } => { + event!(Level::TRACE, "sending: {:?}", signal); let req = SignalRequest { - message: Some(msg.signal), + message: Some(signal), }; let write_res = ws_writer.send(Message::Binary(req.encode_to_vec())).await; if let Err(err) = write_res { - event!(Level::ERROR, "failed to send message to ws: {:?}", err); - let _ = msg.response_chn.send(Err(err.into())); + event!(Level::ERROR, "failed to send signal: {:?}", err); + let _ = response_chn.send(Err(err.into())); break; } - let _ = msg.response_chn.send(Ok(())); + let _ = response_chn.send(Ok(())); + } + Pong { ping_data } => { + if let Err(err) = ws_writer.send(Message::Pong(ping_data)).await { + event!(Level::ERROR, "failed to send pong message: {:?}", err); + } + } + } + } + + let _ = ws_writer + .send(Message::Close(Some(CloseFrame { + code: CloseCode::Normal, + reason: "disconnected by client".into(), + }))) + .await; + let _ = ws_writer.flush().await; + } + + async fn ws_read( + mut read_receiver: mpsc::Receiver, + mut ws_reader: SplitStream, + write_tx: mpsc::Sender, + ) { + while let Some(RecvMessage::Signal { mut response_chn }) = read_receiver.recv().await { + tokio::select! { + read = Self::handle_msg(&mut ws_reader, &write_tx) => { + let _ = response_chn.send(read); + } + _ = poll_fn(|cx| response_chn.poll_closed(cx)) => { + continue; // Cancelled }, - _ = (&mut shutdown_receiver) => { - let _ = ws_writer.send(Message::Close(Some(CloseFrame { - code: CloseCode::Normal, - reason: "disconnected by client".into() - }))).await; - let _ = ws_writer.flush().await; - break; + } + } + } + + async fn handle_msg( + ws_reader: &mut SplitStream, + write_tx: &mpsc::Sender, + ) -> Option { + loop { + let read = ws_reader.next().await?; + match read { + Ok(Message::Binary(data)) => { + let res = SignalResponse::decode(data.as_slice()) + .expect("failed to decode SignalResponse"); + event!(Level::TRACE, "received: {:?}", res); + return Some(res.message.unwrap()); + } + Ok(Message::Ping(data)) => { + let _ = write_tx.send(Pong { ping_data: data }); + continue; + } + Ok(Message::Close(close)) => { + event!(Level::DEBUG, "server closed the connection: {:?}", close); + return None; + } + _ => { + event!(Level::ERROR, "unhandled websocket message {:?}", read); + return None; } } } } - - #[tracing::instrument] - async fn ws_read( - mut read_receiver: mpsc::Receiver, - mut ws_reader: SplitStream, - mut shutdown_receiver: oneshot::Receiver<()>, - ) { - loop { - tokio::select! { - Some(mut msg) = read_receiver.recv() => { - tokio::select! { - Some(read) = ws_reader.next() => { - match read { - Ok(Message::Binary(data)) => { - let res = SignalResponse::decode(data.as_slice()).expect("failed to decode SignalResponse"); - let signal = res.message.unwrap(); - event!(Level::TRACE, "received: {:?}", signal); - let _ = msg.response_chn.send(Some(signal)); - } - _ => { - event!(Level::ERROR, "unhandled websocket message {:?}", read); - let _ = msg.response_chn.send(None); - } - } - }, - _ = poll_fn(|cx| msg.response_chn.poll_closed(cx)) => { - continue; // Cancelled - }, - else => { - break; // Connection closed - } - } - }, - _ = (&mut shutdown_receiver) => break - } - } - } } diff --git a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/jsep.h b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/jsep.h index 2436ec1..fa2e03a 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/jsep.h +++ b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/jsep.h @@ -18,11 +18,12 @@ class IceCandidate { public: explicit IceCandidate( std::unique_ptr ice_candidate); - + rust::String sdp_mid() const; int sdp_mline_index() const; - rust::String candidate() const; // TODO(theomonnom) Return livekit::Candidate instead of rust::String - + rust::String candidate() const; // TODO(theomonnom) Return livekit::Candidate + // instead of rust::String + rust::String stringify() const; std::unique_ptr release(); @@ -30,7 +31,9 @@ class IceCandidate { std::unique_ptr ice_candidate_; }; -std::unique_ptr create_ice_candidate(rust::String sdp_mid, int sdp_mline_index, rust::String sdp); +std::unique_ptr create_ice_candidate(rust::String sdp_mid, + int sdp_mline_index, + rust::String sdp); static std::unique_ptr _unique_ice_candidate() { return nullptr; // Ignore @@ -49,7 +52,9 @@ class SessionDescription { std::unique_ptr session_description_; }; -std::unique_ptr create_session_description(SdpType type, rust::String sdp); +std::unique_ptr create_session_description( + SdpType type, + rust::String sdp); static std::unique_ptr _unique_session_description() { return nullptr; // Ignore diff --git a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection.h b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection.h index f929a0a..e60c202 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection.h +++ b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection.h @@ -69,7 +69,8 @@ create_native_add_ice_candidate_observer( class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver { public: - explicit NativePeerConnectionObserver(std::shared_ptr rtc_runtime, + explicit NativePeerConnectionObserver( + std::shared_ptr rtc_runtime, rust::Box observer); void OnSignalingChange( diff --git a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection_factory.h b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection_factory.h index e296b73..729c280 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection_factory.h +++ b/crates/livekit-webrtc/libwebrtc-sys/include/livekit/peer_connection_factory.h @@ -28,7 +28,8 @@ class PeerConnectionFactory { rtc::scoped_refptr peer_factory_; }; -std::unique_ptr create_peer_connection_factory(std::shared_ptr rtc_runtime); +std::unique_ptr create_peer_connection_factory( + std::shared_ptr rtc_runtime); std::unique_ptr create_rtc_configuration( RTCConfiguration conf); } // namespace livekit diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.cpp b/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.cpp index 03bbe43..72f3c65 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.cpp +++ b/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.cpp @@ -13,7 +13,8 @@ namespace livekit { DataChannel::DataChannel( std::shared_ptr rtc_runtime, rtc::scoped_refptr data_channel) - : rtc_runtime_(std::move(rtc_runtime)), data_channel_(std::move(data_channel)) {} + : rtc_runtime_(std::move(rtc_runtime)), + data_channel_(std::move(data_channel)) {} void DataChannel::register_observer(NativeDataChannelObserver& observer) { data_channel_->RegisterObserver(&observer); diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.rs b/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.rs index a96e2d2..4ae9983 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/data_channel.rs @@ -1,4 +1,4 @@ -use std::fmt::{Debug, Formatter}; +use std::fmt::Debug; use std::slice; #[cxx::bridge(namespace = "livekit")] diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/jsep.rs b/crates/livekit-webrtc/libwebrtc-sys/src/jsep.rs index 1a3fadb..b631665 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/jsep.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/jsep.rs @@ -71,7 +71,7 @@ pub mod ffi { fn create_session_description(sdp_type: SdpType, sdp: String) -> Result>; fn _unique_ice_candidate() -> UniquePtr; // Ignore - fn _unique_session_description() -> UniquePtr; // Ignore + fn _unique_session_description() -> UniquePtr; // Ignore } } @@ -84,9 +84,11 @@ impl Display for ffi::SdpParseError { } unsafe impl Send for ffi::SessionDescription {} + unsafe impl Sync for ffi::SessionDescription {} unsafe impl Send for ffi::IceCandidate {} + unsafe impl Sync for ffi::IceCandidate {} impl ffi::SdpParseError { diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.cpp b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.cpp index 5ebde8b..203c164 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.cpp +++ b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.cpp @@ -152,7 +152,8 @@ void NativePeerConnectionObserver::OnRemoveStream( void NativePeerConnectionObserver::OnDataChannel( rtc::scoped_refptr data_channel) { - observer_->on_data_channel(std::make_unique(rtc_runtime_, data_channel)); + observer_->on_data_channel( + std::make_unique(rtc_runtime_, data_channel)); } void NativePeerConnectionObserver::OnRenegotiationNeeded() { diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.rs b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.rs index a3b245d..bb32da8 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection.rs @@ -1,4 +1,5 @@ -use std::fmt::{Debug, Formatter}; +use std::fmt::Debug; + use cxx::UniquePtr; use crate::candidate::ffi::Candidate; @@ -259,21 +260,27 @@ pub mod ffi { // https://webrtc.github.io/webrtc-org/native-code/native-apis/ unsafe impl Send for ffi::PeerConnection {} + unsafe impl Sync for ffi::PeerConnection {} unsafe impl Send for ffi::NativePeerConnectionObserver {} + unsafe impl Sync for ffi::NativePeerConnectionObserver {} unsafe impl Sync for ffi::NativeAddIceCandidateObserver {} + unsafe impl Send for ffi::NativeAddIceCandidateObserver {} unsafe impl Sync for ffi::NativeSetRemoteSdpObserverHandle {} + unsafe impl Send for ffi::NativeSetRemoteSdpObserverHandle {} unsafe impl Sync for ffi::NativeSetLocalSdpObserverHandle {} + unsafe impl Send for ffi::NativeSetLocalSdpObserverHandle {} unsafe impl Sync for ffi::NativeCreateSdpObserverHandle {} + unsafe impl Send for ffi::NativeCreateSdpObserverHandle {} impl Default for ffi::RTCOfferAnswerOptions { diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.cpp b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.cpp index 040f5a3..985d8a3 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.cpp +++ b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.cpp @@ -67,7 +67,8 @@ std::unique_ptr PeerConnectionFactory::create_peer_connection( return std::make_unique(rtc_runtime_, result.value()); } -std::unique_ptr create_peer_connection_factory(std::shared_ptr rtc_runtime) { +std::unique_ptr create_peer_connection_factory( + std::shared_ptr rtc_runtime) { return std::make_unique(std::move(rtc_runtime)); } diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.rs b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.rs index 82bbebc..690f605 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/peer_connection_factory.rs @@ -1,8 +1,3 @@ -use std::any::Any; - -use crate::jsep::CreateSdpObserver; -use crate::peer_connection::PeerConnectionObserver; - #[cxx::bridge(namespace = "livekit")] pub mod ffi { #[derive(Debug, Clone)] @@ -40,7 +35,7 @@ pub mod ffi { type PeerConnection = crate::peer_connection::ffi::PeerConnection; type NativePeerConnectionObserver = - crate::peer_connection::ffi::NativePeerConnectionObserver; + crate::peer_connection::ffi::NativePeerConnectionObserver; type PeerConnectionFactory; type NativeRTCConfiguration; type RTCRuntime = crate::webrtc::ffi::RTCRuntime; @@ -59,4 +54,5 @@ pub mod ffi { } unsafe impl Send for ffi::PeerConnectionFactory {} + unsafe impl Sync for ffi::PeerConnectionFactory {} diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/rtc_error.rs b/crates/livekit-webrtc/libwebrtc-sys/src/rtc_error.rs index 0e79f13..77ebe9b 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/rtc_error.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/rtc_error.rs @@ -1,7 +1,8 @@ -use crate::rtc_error::ffi::RTCErrorType; use std::error::Error; use std::fmt::{Display, Formatter}; +use crate::rtc_error::ffi::RTCErrorType; + // cxx doesn't support custom Exception type, so we serialize RTCError inside the cxx::Exception "what" string #[cxx::bridge(namespace = "livekit")] diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/rtp_receiver.rs b/crates/livekit-webrtc/libwebrtc-sys/src/rtp_receiver.rs index 456d283..6b6cc92 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/rtp_receiver.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/rtp_receiver.rs @@ -1,5 +1,3 @@ -use cxx::UniquePtr; - #[cxx::bridge(namespace = "livekit")] pub mod ffi { unsafe extern "C++" { diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/rtp_transceiver.rs b/crates/livekit-webrtc/libwebrtc-sys/src/rtp_transceiver.rs index 6fc45eb..1350f72 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/rtp_transceiver.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/rtp_transceiver.rs @@ -1,5 +1,3 @@ -use cxx::UniquePtr; - #[cxx::bridge(namespace = "livekit")] pub mod ffi { unsafe extern "C++" { diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.cpp b/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.cpp index 44c6436..bee2fc1 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.cpp +++ b/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.cpp @@ -8,7 +8,7 @@ namespace livekit { RTCRuntime::RTCRuntime() { - //rtc::LogMessage::LogToDebug(rtc::LS_INFO); + // rtc::LogMessage::LogToDebug(rtc::LS_INFO); RTC_LOG(LS_INFO) << "RTCRuntime()"; RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()"; diff --git a/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.rs b/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.rs index 71120e3..f309843 100644 --- a/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.rs +++ b/crates/livekit-webrtc/libwebrtc-sys/src/webrtc.rs @@ -1,5 +1,3 @@ -use cxx::UniquePtr; - #[cxx::bridge(namespace = "livekit")] pub mod ffi { unsafe extern "C++" { @@ -12,4 +10,5 @@ pub mod ffi { } unsafe impl Send for ffi::RTCRuntime {} + unsafe impl Sync for ffi::RTCRuntime {} diff --git a/crates/livekit-webrtc/src/data_channel.rs b/crates/livekit-webrtc/src/data_channel.rs index 4056053..9af7620 100644 --- a/crates/livekit-webrtc/src/data_channel.rs +++ b/crates/livekit-webrtc/src/data_channel.rs @@ -1,12 +1,12 @@ use std::error::Error; use std::fmt::{Debug, Display, Formatter}; use std::sync::{Arc, Mutex}; + use cxx::UniquePtr; use log::trace; use libwebrtc_sys::data_channel as sys_dc; - -pub use sys_dc::ffi::{Priority, DataState}; +pub use sys_dc::ffi::{DataState, Priority}; pub struct DataChannel { cxx_handle: UniquePtr, @@ -31,7 +31,7 @@ impl Display for DataSendError { } } -impl Error for DataSendError { } +impl Error for DataSendError {} impl DataChannel { pub(crate) fn new(cxx_handle: UniquePtr) -> Self { @@ -100,7 +100,8 @@ impl DataChannel { } pub type OnStateChangeHandler = Box; -pub type OnMessageHandler = Box; // data, is_binary +pub type OnMessageHandler = Box; +// data, is_binary pub type OnBufferedAmountChangeHandler = Box; struct InternalDataChannelObserver { diff --git a/crates/livekit-webrtc/src/jsep.rs b/crates/livekit-webrtc/src/jsep.rs index 88ddcf5..8117830 100644 --- a/crates/livekit-webrtc/src/jsep.rs +++ b/crates/livekit-webrtc/src/jsep.rs @@ -1,8 +1,9 @@ -use std::fmt::{Debug, Display, Formatter, write}; -use cxx::UniquePtr; -use libwebrtc_sys::jsep as sys_jsep; +use std::fmt::{Debug, Display, Formatter}; -pub use sys_jsep::ffi::{SdpType, SdpParseError}; +use cxx::UniquePtr; + +use libwebrtc_sys::jsep as sys_jsep; +pub use sys_jsep::ffi::{SdpParseError, SdpType}; // TODO Maybe we can replace that by a serialized IceCandidateInit pub struct IceCandidate { diff --git a/crates/livekit-webrtc/src/peer_connection.rs b/crates/livekit-webrtc/src/peer_connection.rs index 9e248b3..2d78e38 100644 --- a/crates/livekit-webrtc/src/peer_connection.rs +++ b/crates/livekit-webrtc/src/peer_connection.rs @@ -363,16 +363,16 @@ pub type OnRenegotiationNeededHandler = Box; pub type OnNegotiationNeededEventHandler = Box; pub type OnIceConnectionChangeHandler = Box; pub type OnStandardizedIceConnectionChangeHandler = - Box; +Box; pub type OnConnectionChangeHandler = Box; pub type OnIceGatheringChangeHandler = Box; pub type OnIceCandidateHandler = Box; pub type OnIceCandidateErrorHandler = - Box; +Box; pub type OnIceCandidatesRemovedHandler = Box) + Send + Sync>; pub type OnIceConnectionReceivingChangeHandler = Box; pub type OnIceSelectedCandidatePairChangedHandler = - Box; +Box; pub type OnAddTrackHandler = Box) + Send + Sync>; pub type OnTrackHandler = Box; pub type OnRemoveTrackHandler = Box; @@ -387,16 +387,16 @@ pub(crate) struct InternalObserver { on_negotiation_needed_event_handler: Arc>>, on_ice_connection_change_handler: Arc>>, on_standardized_ice_connection_change_handler: - Arc>>, + Arc>>, on_connection_change_handler: Arc>>, on_ice_gathering_change_handler: Arc>>, on_ice_candidate_handler: Arc>>, on_ice_candidate_error_handler: Arc>>, on_ice_candidates_removed_handler: Arc>>, on_ice_connection_receiving_change_handler: - Arc>>, + Arc>>, on_ice_selected_candidate_pair_changed_handler: - Arc>>, + Arc>>, on_add_track_handler: Arc>>, on_track_handler: Arc>>, on_remove_track_handler: Arc>>, @@ -626,6 +626,7 @@ impl sys_pc::PeerConnectionObserver for InternalObserver { mod tests { use log::trace; use tokio::sync::mpsc; + use libwebrtc_sys::peer_connection::ffi::RTCOfferAnswerOptions; use libwebrtc_sys::peer_connection_factory::ffi::{ContinualGatheringPolicy, IceTransportsType}; @@ -652,7 +653,7 @@ mod tests { password: "".into(), }], continual_gathering_policy: ContinualGatheringPolicy::GatherOnce, - ice_transport_type: IceTransportsType::All + ice_transport_type: IceTransportsType::All, }; let mut bob = factory.create_peer_connection(config.clone()).unwrap(); diff --git a/crates/livekit-webrtc/src/rtc_error.rs b/crates/livekit-webrtc/src/rtc_error.rs index 86c81e1..e054cf4 100644 --- a/crates/livekit-webrtc/src/rtc_error.rs +++ b/crates/livekit-webrtc/src/rtc_error.rs @@ -1,2 +1,3 @@ // TODO(theomonnom) Wrap the RTCError ffi so we can use Option(u16) pub use libwebrtc_sys::rtc_error::ffi::RTCError; + diff --git a/crates/livekit-webrtc/src/webrtc.rs b/crates/livekit-webrtc/src/webrtc.rs index 684bd4e..bc71c02 100644 --- a/crates/livekit-webrtc/src/webrtc.rs +++ b/crates/livekit-webrtc/src/webrtc.rs @@ -1,4 +1,4 @@ -use cxx::{SharedPtr}; +use cxx::SharedPtr; use libwebrtc_sys::webrtc as sys_rtc; diff --git a/examples/Cargo.lock b/examples/Cargo.lock new file mode 100644 index 0000000..1bc62fc --- /dev/null +++ b/examples/Cargo.lock @@ -0,0 +1,1347 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "cxx" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f39818dcfc97d45b03953c1292efc4e80954e1583c4aa770bac1383e2310a4" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e580d70777c116df50c390d1211993f62d40302881e54d4b79727acb83d0199" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56a46460b88d1cec95112c8c363f0e2c39afdb237f60583b0b36343bf627ea9c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" + +[[package]] +name = "futures-executor" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" + +[[package]] +name = "futures-macro" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" + +[[package]] +name = "futures-task" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" + +[[package]] +name = "futures-util" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" + +[[package]] +name = "jobserver" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" + +[[package]] +name = "libwebrtc-sys" +version = "0.1.0" +dependencies = [ + "cc", + "cxx", + "cxx-build", + "glob", + "log", + "regex", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "livekit" +version = "0.1.0" +dependencies = [ + "livekit-core", +] + +[[package]] +name = "livekit-core" +version = "0.1.0" +dependencies = [ + "anyhow", + "futures", + "futures-util", + "lazy_static", + "livekit-webrtc", + "prost", + "prost-build", + "prost-types", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "url", +] + +[[package]] +name = "livekit-webrtc" +version = "0.1.0" +dependencies = [ + "cxx", + "libwebrtc-sys", + "log", + "thiserror", + "tokio", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] +name = "openssl" +version = "0.10.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro2" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "regex", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" +dependencies = [ + "bytes", + "prost", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "simple_room" +version = "0.1.0" +dependencies = [ + "livekit", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +dependencies = [ + "futures-util", + "log", + "native-tls", + "tokio", + "tokio-native-tls", + "tungstenite", +] + +[[package]] +name = "tracing" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" +dependencies = [ + "ansi_term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "tungstenite" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "native-tls", + "rand", + "sha-1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000..5f00359 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["*"] +exclude = ["target"] \ No newline at end of file diff --git a/examples/simple_room/Cargo.toml b/examples/simple_room/Cargo.toml new file mode 100644 index 0000000..85f7276 --- /dev/null +++ b/examples/simple_room/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "simple_room" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = { version = "1", features = ["full"] } +tracing = "0.1" +tracing-subscriber = "0.3" +livekit = { path = "../.." } \ No newline at end of file diff --git a/examples/simple_room/src/main.rs b/examples/simple_room/src/main.rs new file mode 100644 index 0000000..d22fecc --- /dev/null +++ b/examples/simple_room/src/main.rs @@ -0,0 +1,19 @@ +use livekit::proto::data_packet; +use livekit::room; + +const URL: &str = "ws://localhost:7880"; +const TOKEN : &str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NjgxMzc0NDgsImlzcyI6IkFQSXpLYkFTaUNWYWtnSiIsIm5hbWUiOiJ3ZWIiLCJuYmYiOjE2NjQ1Mzc0NDgsInN1YiI6IndlYiIsInZpZGVvIjp7InJvb21DcmVhdGUiOnRydWUsInJvb21Kb2luIjp0cnVlfX0.6VMDdXJYrW3KWrEzxx4hzbmMQnjQIRILQ48Qrbx5j44"; + +// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NjgxMzc0NDgsImlzcyI6IkFQSXpLYkFTaUNWYWtnSiIsIm5hbWUiOiJ3ZWIiLCJuYmYiOjE2NjQ1Mzc0NDgsInN1YiI6IndlYiIsInZpZGVvIjp7InJvb21DcmVhdGUiOnRydWUsInJvb21Kb2luIjp0cnVlfX0.6VMDdXJYrW3KWrEzxx4hzbmMQnjQIRILQ48Qrbx5j44 + +#[tokio::main] +async fn main() -> Result<(), room::RoomError> { + tracing_subscriber::fmt::init(); + + let mut room = room::connect(URL, TOKEN).await?; + room.local_participant() + .publish_data(b"this is a test", data_packet::Kind::Reliable) + .await?; + + Ok(()) +} diff --git a/src/lib.rs b/src/lib.rs index 8b13789..fe7ff25 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,2 @@ - +// export everything inside livekit-core +pub use livekit_core::*; \ No newline at end of file