feat: server sdk (#47)
* New webrtc build scripts (Still not integrated within the SDK) * New livekit-api crate (Integrate the server sdk protocol of livekit) * Moved livekit-utils to livekit-protocol
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::track;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/livekit.rs"));
|
||||
use livekit_protocol::*;
|
||||
|
||||
// Conversions
|
||||
impl TryFrom<TrackType> for track::TrackKind {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use self::track::RemoteTrack;
|
||||
use crate::participant::ConnectionQuality;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::EngineError;
|
||||
use livekit_protocol as proto;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::prelude::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::options::compute_video_encodings;
|
||||
use crate::options::video_layers_from_encodings;
|
||||
use crate::options::TrackPublishOptions;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::RtcEngine;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::rtp_parameters::RtpEncodingParameters;
|
||||
use parking_lot::RwLockReadGuard;
|
||||
use std::collections::HashMap;
|
||||
@@ -150,6 +150,7 @@ impl LocalParticipant {
|
||||
participant_sid: self.sid().to_string(),
|
||||
payload: data.to_vec(),
|
||||
destination_sids: vec![],
|
||||
..Default::default()
|
||||
})),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::track::TrackError;
|
||||
use livekit_utils::enum_dispatch;
|
||||
use livekit_utils::observer::Dispatcher;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_protocol::enum_dispatch;
|
||||
use livekit_protocol::observer::Dispatcher;
|
||||
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU8, Ordering};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::{ConnectionQuality, ParticipantInner};
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::track::TrackError;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc as rtc;
|
||||
use parking_lot::RwLockReadGuard;
|
||||
use rtc::prelude::MediaStreamTrack;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::TrackPublicationInner;
|
||||
use crate::id::TrackSid;
|
||||
use crate::options::TrackPublishOptions;
|
||||
use crate::proto;
|
||||
use crate::track::{LocalTrack, Track, TrackDimension, TrackKind, TrackSource};
|
||||
use livekit_protocol as proto;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::track::{TrackDimension, TrackEvent};
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::track::Track;
|
||||
use futures_util::stream::StreamExt;
|
||||
use livekit_utils::enum_dispatch;
|
||||
use livekit_utils::observer::Dispatcher;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_protocol::enum_dispatch;
|
||||
use livekit_protocol::observer::Dispatcher;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::TrackPublicationInner;
|
||||
use crate::id::TrackSid;
|
||||
use crate::proto;
|
||||
use crate::track::{RemoteTrack, Track, TrackDimension, TrackKind, TrackSource};
|
||||
use livekit_protocol as proto;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::participant::ConnectionQuality;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::{EngineEvent, EngineEvents, EngineResult, RtcEngine};
|
||||
use crate::signal_client::SignalOptions;
|
||||
use crate::{RoomError, RoomEvent, RoomResult, SimulateScenario};
|
||||
use livekit_utils::observer::Dispatcher;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_protocol::observer::Dispatcher;
|
||||
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::atomic::{AtomicU8, Ordering};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::TrackInner;
|
||||
use crate::options::AudioCaptureOptions;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::lk_runtime::LkRuntime;
|
||||
use crate::webrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc as rtc;
|
||||
use parking_lot::Mutex;
|
||||
use rtc::audio_source::native::NativeAudioSource;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::TrackInner;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::lk_runtime::LkRuntime;
|
||||
use crate::{options::VideoCaptureOptions, prelude::*};
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc as rtc;
|
||||
use livekit_webrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use livekit_utils::enum_dispatch;
|
||||
use livekit_utils::observer::Dispatcher;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_protocol::enum_dispatch;
|
||||
use livekit_protocol::observer::Dispatcher;
|
||||
use livekit_webrtc as rtc;
|
||||
use parking_lot::Mutex;
|
||||
use rtc::MediaType;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::TrackInner;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc as rtc;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::TrackInner;
|
||||
use crate::prelude::*;
|
||||
use crate::proto;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc as rtc;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use crate::options::TrackPublishOptions;
|
||||
use crate::prelude::LocalTrack;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::lk_runtime::LkRuntime;
|
||||
use crate::rtc_engine::rtc_session::{RtcSession, SessionEvent, SessionEvents, SessionInfo};
|
||||
use crate::signal_client::{SignalError, SignalOptions};
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::prelude::*;
|
||||
use livekit_webrtc::session_description::SdpParseError;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use tokio::sync::RwLock as AsyncRwLock;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::proto;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::prelude::*;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::time::Duration;
|
||||
use tracing::{debug, event, Level};
|
||||
use tracing::{event, Level};
|
||||
|
||||
const NEGOTIATION_FREQUENCY: Duration = Duration::from_millis(150);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::peer_transport::PeerTransport;
|
||||
use crate::proto;
|
||||
use crate::rtc_engine::peer_transport::OnOfferCreated;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::{self as rtc, prelude::*};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, error};
|
||||
|
||||
@@ -4,9 +4,10 @@ use crate::prelude::TrackKind;
|
||||
use crate::rtc_engine::lk_runtime::LkRuntime;
|
||||
use crate::rtc_engine::peer_transport::PeerTransport;
|
||||
use crate::rtc_engine::rtc_events::{RtcEvent, RtcEvents};
|
||||
use crate::signal_client;
|
||||
use crate::signal_client::{SignalClient, SignalEvent, SignalEvents, SignalOptions};
|
||||
use crate::track::LocalTrack;
|
||||
use crate::{proto, signal_client};
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use prost::Message;
|
||||
@@ -157,7 +158,21 @@ impl RtcSession {
|
||||
debug!("received JoinResponse: {:?}", join_response);
|
||||
|
||||
let (rtc_emitter, rtc_events) = mpsc::unbounded_channel();
|
||||
let rtc_config = RtcConfiguration::from(join_response.clone());
|
||||
let rtc_config = RtcConfiguration {
|
||||
ice_servers: {
|
||||
let mut servers = vec![];
|
||||
for ice_server in join_response.ice_servers.clone() {
|
||||
servers.push(IceServer {
|
||||
urls: ice_server.urls,
|
||||
username: ice_server.username,
|
||||
password: ice_server.credential,
|
||||
})
|
||||
}
|
||||
servers
|
||||
},
|
||||
continual_gathering_policy: ContinualGatheringPolicy::GatherContinually,
|
||||
ice_transport_type: IceTransportsType::All,
|
||||
};
|
||||
|
||||
let mut publisher_pc = PeerTransport::new(
|
||||
lk_runtime
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::proto;
|
||||
use crate::signal_client::signal_stream::SignalStream;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_webrtc::prelude::*;
|
||||
use parking_lot::RwLock;
|
||||
use std::fmt::Debug;
|
||||
@@ -114,29 +114,9 @@ impl SignalClient {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<proto::JoinResponse> for RtcConfiguration {
|
||||
fn from(join_response: proto::JoinResponse) -> Self {
|
||||
Self {
|
||||
ice_servers: {
|
||||
let mut servers = vec![];
|
||||
for ice_server in join_response.ice_servers.clone() {
|
||||
servers.push(IceServer {
|
||||
urls: ice_server.urls,
|
||||
username: ice_server.username,
|
||||
password: ice_server.credential,
|
||||
})
|
||||
}
|
||||
servers
|
||||
},
|
||||
continual_gathering_policy: ContinualGatheringPolicy::GatherContinually,
|
||||
ice_transport_type: IceTransportsType::All,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod utils {
|
||||
use crate::proto::{signal_response, JoinResponse};
|
||||
use crate::signal_client::{SignalError, SignalEvent, SignalResult, JOIN_RESPONSE_TIMEOUT};
|
||||
use livekit_protocol as proto;
|
||||
use tokio::time::timeout;
|
||||
use tokio_tungstenite::tungstenite::Error as WsError;
|
||||
use tracing::{event, instrument, Level};
|
||||
@@ -146,11 +126,13 @@ pub mod utils {
|
||||
#[instrument(level = Level::DEBUG, skip(receiver))]
|
||||
pub(crate) async fn next_join_response(
|
||||
receiver: &mut SignalEvents,
|
||||
) -> SignalResult<JoinResponse> {
|
||||
) -> SignalResult<proto::JoinResponse> {
|
||||
let join = async {
|
||||
while let Some(event) = receiver.recv().await {
|
||||
match event {
|
||||
SignalEvent::Signal(signal_response::Message::Join(join)) => return Ok(join),
|
||||
SignalEvent::Signal(proto::signal_response::Message::Join(join)) => {
|
||||
return Ok(join)
|
||||
}
|
||||
SignalEvent::Close => break,
|
||||
SignalEvent::Open => continue,
|
||||
_ => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::proto;
|
||||
use crate::signal_client::{SignalEmitter, SignalEvent, SignalOptions, SignalResult};
|
||||
use futures_util::stream::{SplitSink, SplitStream};
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use livekit_protocol as proto;
|
||||
use prost::Message as ProstMessage;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
||||
Reference in New Issue
Block a user